当前位置: 首页>>代码示例>>C#>>正文


C# EventDeclaration.AddAnnotation方法代码示例

本文整理汇总了C#中EventDeclaration.AddAnnotation方法的典型用法代码示例。如果您正苦于以下问题:C# EventDeclaration.AddAnnotation方法的具体用法?C# EventDeclaration.AddAnnotation怎么用?C# EventDeclaration.AddAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventDeclaration的用法示例。


在下文中一共展示了EventDeclaration.AddAnnotation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateEvent

		AttributedNode CreateEvent(EventDefinition eventDef)
		{
			if (eventDef.AddMethod != null && eventDef.AddMethod.IsAbstract) {
				// An abstract event cannot be custom
				EventDeclaration astEvent = new EventDeclaration();
				ConvertCustomAttributes(astEvent, eventDef);
				astEvent.AddAnnotation(eventDef);
				astEvent.Variables.Add(new VariableInitializer(CleanName(eventDef.Name)));
				astEvent.ReturnType = ConvertType(eventDef.EventType, eventDef);
				if (!eventDef.DeclaringType.IsInterface)
					astEvent.Modifiers = ConvertModifiers(eventDef.AddMethod);
				return astEvent;
			} else {
				CustomEventDeclaration astEvent = new CustomEventDeclaration();
				ConvertCustomAttributes(astEvent, eventDef);
				astEvent.AddAnnotation(eventDef);
				astEvent.Name = CleanName(eventDef.Name);
				astEvent.ReturnType = ConvertType(eventDef.EventType, eventDef);
				if (eventDef.AddMethod == null || !eventDef.AddMethod.HasOverrides)
					astEvent.Modifiers = ConvertModifiers(eventDef.AddMethod);
				else
					astEvent.PrivateImplementationType = ConvertType(eventDef.AddMethod.Overrides.First().DeclaringType);
				if (eventDef.AddMethod != null) {
					// Create mapping - used in debugger
					MemberMapping methodMapping = eventDef.AddMethod.CreateCodeMapping(this.CodeMappings);
					
					astEvent.AddAccessor = new Accessor {
						Body = CreateMethodBody(eventDef.AddMethod)
					}.WithAnnotation(eventDef.AddMethod);
					ConvertAttributes(astEvent.AddAccessor, eventDef.AddMethod);
					
					astEvent.AddAccessor.WithAnnotation(methodMapping);
				}
				if (eventDef.RemoveMethod != null) {
					// Create mapping - used in debugger
					MemberMapping methodMapping = eventDef.RemoveMethod.CreateCodeMapping(this.CodeMappings);
					
					astEvent.RemoveAccessor = new Accessor {
						Body = CreateMethodBody(eventDef.RemoveMethod)
					}.WithAnnotation(eventDef.RemoveMethod);
					ConvertAttributes(astEvent.RemoveAccessor, eventDef.RemoveMethod);
					
					astEvent.RemoveAccessor.WithAnnotation(methodMapping);
				}
				MethodDefinition accessor = eventDef.AddMethod ?? eventDef.RemoveMethod;
				if (accessor.IsVirtual ^ !accessor.IsNewSlot) {
					if (TypesHierarchyHelpers.FindBaseMethods(accessor).Any())
						astEvent.Modifiers |= Modifiers.New;
				}
				return astEvent;
			}
		}
开发者ID:ThomasZitzler,项目名称:ILSpy,代码行数:52,代码来源:AstBuilder.cs

示例2: ConvertEvent

 EntityDeclaration ConvertEvent(IEvent ev)
 {
     if (this.UseCustomEvents) {
         CustomEventDeclaration decl = new CustomEventDeclaration();
         decl.Modifiers = GetMemberModifiers(ev);
         if (ShowAttributes) {
             decl.Attributes.AddRange (ev.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a))));
         }
         if (AddResolveResultAnnotations) {
             decl.AddAnnotation(new MemberResolveResult(null, ev));
         }
         decl.ReturnType = ConvertType(ev.ReturnType);
         decl.Name = ev.Name;
         decl.AddAccessor    = ConvertAccessor(ev.AddAccessor, ev.Accessibility, true);
         decl.RemoveAccessor = ConvertAccessor(ev.RemoveAccessor, ev.Accessibility, true);
         return decl;
     } else {
         EventDeclaration decl = new EventDeclaration();
         decl.Modifiers = GetMemberModifiers(ev);
         if (ShowAttributes) {
             decl.Attributes.AddRange (ev.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a))));
         }
         if (AddResolveResultAnnotations) {
             decl.AddAnnotation(new MemberResolveResult(null, ev));
         }
         decl.ReturnType = ConvertType(ev.ReturnType);
         decl.Variables.Add(new VariableInitializer(ev.Name));
         return decl;
     }
 }
开发者ID:yyp2003net,项目名称:NRefactory,代码行数:30,代码来源:TypeSystemAstBuilder.cs

示例3: CreateEvent

		AttributedNode CreateEvent(EventDefinition eventDef)
		{
			if (eventDef.AddMethod != null && eventDef.AddMethod.IsAbstract) {
				// An abstract event cannot be custom
				EventDeclaration astEvent = new EventDeclaration();
				ConvertCustomAttributes(astEvent, eventDef);
				astEvent.AddAnnotation(eventDef);
				astEvent.Variables.Add(new VariableInitializer(CleanName(eventDef.Name)));
				astEvent.ReturnType = ConvertType(eventDef.EventType, eventDef);
				if (!eventDef.DeclaringType.IsInterface)
					astEvent.Modifiers = ConvertModifiers(eventDef.AddMethod);
				return astEvent;
			} else {
				CustomEventDeclaration astEvent = new CustomEventDeclaration();
				ConvertCustomAttributes(astEvent, eventDef);
				astEvent.AddAnnotation(eventDef);
				astEvent.Name = CleanName(eventDef.Name);
				astEvent.ReturnType = ConvertType(eventDef.EventType, eventDef);
				if (eventDef.AddMethod == null || !eventDef.AddMethod.HasOverrides)
					astEvent.Modifiers = ConvertModifiers(eventDef.AddMethod);
				else
					astEvent.PrivateImplementationType = ConvertType(eventDef.AddMethod.Overrides.First().DeclaringType);
				if (eventDef.AddMethod != null) {
					astEvent.AddAccessor = new Accessor {
						Body = AstMethodBodyBuilder.CreateMethodBody(eventDef.AddMethod, context)
					}.WithAnnotation(eventDef.AddMethod);
					ConvertAttributes(astEvent.AddAccessor, eventDef.AddMethod);
				}
				if (eventDef.RemoveMethod != null) {
					astEvent.RemoveAccessor = new Accessor {
						Body = AstMethodBodyBuilder.CreateMethodBody(eventDef.RemoveMethod, context)
					}.WithAnnotation(eventDef.RemoveMethod);
					ConvertAttributes(astEvent.RemoveAccessor, eventDef.RemoveMethod);
				}
				return astEvent;
			}
		}
开发者ID:liquidboy,项目名称:ILSpy,代码行数:37,代码来源:AstBuilder.cs


注:本文中的EventDeclaration.AddAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。