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


C# PropertyDeclaration.AddAnnotation方法代码示例

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


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

示例1: CreateProperty

		PropertyDeclaration CreateProperty(PropertyDefinition propDef)
		{
			PropertyDeclaration astProp = new PropertyDeclaration();
			astProp.AddAnnotation(propDef);
			var accessor = propDef.GetMethod ?? propDef.SetMethod;
			Modifiers getterModifiers = Modifiers.None;
			Modifiers setterModifiers = Modifiers.None;
			if (!propDef.DeclaringType.IsInterface && !accessor.HasOverrides) {
				getterModifiers = ConvertModifiers(propDef.GetMethod);
				setterModifiers = ConvertModifiers(propDef.SetMethod);
				astProp.Modifiers = FixUpVisibility(getterModifiers | setterModifiers);
			} else if (accessor.HasOverrides) {
				astProp.PrivateImplementationType = ConvertType(accessor.Overrides.First().DeclaringType);
			}
			astProp.Name = CleanName(propDef.Name);
			astProp.ReturnType = ConvertType(propDef.PropertyType, propDef);
			if (propDef.GetMethod != null) {
				astProp.Getter = new Accessor();
				astProp.Getter.Body = AstMethodBodyBuilder.CreateMethodBody(propDef.GetMethod, context);
				astProp.AddAnnotation(propDef.GetMethod);
				ConvertAttributes(astProp.Getter, propDef.GetMethod);
				
				if ((getterModifiers & Modifiers.VisibilityMask) != (astProp.Modifiers & Modifiers.VisibilityMask))
					astProp.Getter.Modifiers = getterModifiers & Modifiers.VisibilityMask;
			}
			if (propDef.SetMethod != null) {
				astProp.Setter = new Accessor();
				astProp.Setter.Body = AstMethodBodyBuilder.CreateMethodBody(propDef.SetMethod, context);
				astProp.Setter.AddAnnotation(propDef.SetMethod);
				ConvertAttributes(astProp.Setter, propDef.SetMethod);
				ConvertCustomAttributes(astProp.Setter, propDef.SetMethod.Parameters.Last(), AttributeTarget.Param);
				
				if ((setterModifiers & Modifiers.VisibilityMask) != (astProp.Modifiers & Modifiers.VisibilityMask))
					astProp.Setter.Modifiers = setterModifiers & Modifiers.VisibilityMask;
			}
			ConvertCustomAttributes(astProp, propDef);
			return astProp;
		}
开发者ID:eldersantos,项目名称:ILSpy,代码行数:38,代码来源:AstBuilder.cs

示例2: ConvertProperty

 PropertyDeclaration ConvertProperty(IProperty property)
 {
     PropertyDeclaration decl = new PropertyDeclaration();
     decl.Modifiers = GetMemberModifiers(property);
     if (ShowAttributes) {
         decl.Attributes.AddRange (property.Attributes.Select ((a) => new AttributeSection (ConvertAttribute (a))));
     }
     if (AddResolveResultAnnotations) {
         decl.AddAnnotation(new MemberResolveResult(null, property));
     }
     decl.ReturnType = ConvertType(property.ReturnType);
     decl.Name = property.Name;
     decl.Getter = ConvertAccessor(property.Getter, property.Accessibility, false);
     decl.Setter = ConvertAccessor(property.Setter, property.Accessibility, true);
     decl.PrivateImplementationType = GetExplicitInterfaceType (property);
     return decl;
 }
开发者ID:yyp2003net,项目名称:NRefactory,代码行数:17,代码来源:TypeSystemAstBuilder.cs

示例3: CreateProperty

		PropertyDeclaration CreateProperty(PropertyDefinition propDef)
		{
			PropertyDeclaration astProp = new PropertyDeclaration();
			astProp.AddAnnotation(propDef);
			astProp.Modifiers = ConvertModifiers(propDef.GetMethod ?? propDef.SetMethod);
			astProp.Name = CleanName(propDef.Name);
			astProp.ReturnType = ConvertType(propDef.PropertyType, propDef);
			if (propDef.GetMethod != null) {
				astProp.Getter = new Accessor {
					Body = AstMethodBodyBuilder.CreateMethodBody(propDef.GetMethod, context)
				}.WithAnnotation(propDef.GetMethod);
				ConvertCustomAttributes(astProp.Getter, propDef.GetMethod);
				ConvertCustomAttributes(astProp.Getter, propDef.GetMethod.MethodReturnType, AttributeTarget.Return);
			}
			if (propDef.SetMethod != null) {
				astProp.Setter = new Accessor {
					Body = AstMethodBodyBuilder.CreateMethodBody(propDef.SetMethod, context)
				}.WithAnnotation(propDef.SetMethod);
				ConvertCustomAttributes(astProp.Setter, propDef.SetMethod);
				ConvertCustomAttributes(astProp.Setter, propDef.SetMethod.MethodReturnType, AttributeTarget.Return);
				ConvertCustomAttributes(astProp.Setter, propDef.SetMethod.Parameters.Last(), AttributeTarget.Param);
			}
			ConvertCustomAttributes(astProp, propDef);
			return astProp;
		}
开发者ID:stgwilli,项目名称:ILSpy,代码行数:25,代码来源:AstBuilder.cs

示例4: CreateProperty

 PropertyDeclaration CreateProperty(PropertyDefinition propDef)
 {
     PropertyDeclaration astProp = new PropertyDeclaration();
     astProp.AddAnnotation(propDef);
     astProp.Modifiers = ConvertModifiers(propDef.GetMethod ?? propDef.SetMethod);
     astProp.Name = propDef.Name;
     astProp.ReturnType = ConvertType(propDef.PropertyType, propDef);
     if (propDef.GetMethod != null) {
         astProp.Getter = new Accessor {
             Body = AstMethodBodyBuilder.CreateMethodBody(propDef.GetMethod, context)
         }.WithAnnotation(propDef.GetMethod);
     }
     if (propDef.SetMethod != null) {
         astProp.Setter = new Accessor {
             Body = AstMethodBodyBuilder.CreateMethodBody(propDef.SetMethod, context)
         }.WithAnnotation(propDef.SetMethod);
     }
     return astProp;
 }
开发者ID:petr-k,项目名称:ILSpy,代码行数:19,代码来源:AstBuilder.cs

示例5: CreateProperty

		MemberDeclaration CreateProperty(PropertyDefinition propDef)
		{
			PropertyDeclaration astProp = new PropertyDeclaration();
			astProp.AddAnnotation(propDef);
			var accessor = propDef.GetMethod ?? propDef.SetMethod;
			Modifiers getterModifiers = Modifiers.None;
			Modifiers setterModifiers = Modifiers.None;
			if (accessor.HasOverrides) {
				astProp.PrivateImplementationType = ConvertType(accessor.Overrides.First().DeclaringType);
			} else if (!propDef.DeclaringType.IsInterface) {
				getterModifiers = ConvertModifiers(propDef.GetMethod);
				setterModifiers = ConvertModifiers(propDef.SetMethod);
				astProp.Modifiers = FixUpVisibility(getterModifiers | setterModifiers);
				try {
					if (accessor.IsVirtual && !accessor.IsNewSlot && (propDef.GetMethod == null || propDef.SetMethod == null)) {
						foreach (var basePropDef in TypesHierarchyHelpers.FindBaseProperties(propDef)) {
							if (basePropDef.GetMethod != null && basePropDef.SetMethod != null) {
								var propVisibilityModifiers = ConvertModifiers(basePropDef.GetMethod) | ConvertModifiers(basePropDef.SetMethod);
								astProp.Modifiers = FixUpVisibility((astProp.Modifiers & ~Modifiers.VisibilityMask) | (propVisibilityModifiers & Modifiers.VisibilityMask));
								break;
							} else if ((basePropDef.GetMethod ?? basePropDef.SetMethod).IsNewSlot) {
								break;
							}
						}
					}
					if (accessor.IsVirtual ^ !accessor.IsNewSlot) {
						if (TypesHierarchyHelpers.FindBaseProperties(propDef).Any())
							astProp.Modifiers |= Modifiers.New;
					}
				} catch (ReferenceResolvingException) {
					// TODO: add some kind of notification (a comment?) about possible problems with decompiled code due to unresolved references.
				}
			}
			astProp.Name = CleanName(propDef.Name);
			astProp.ReturnType = ConvertType(propDef.PropertyType, propDef);
			if (propDef.GetMethod != null) {
				// Create mapping - used in debugger
				MemberMapping methodMapping = propDef.GetMethod.CreateCodeMapping(this.CodeMappings);
				
				astProp.Getter = new Accessor();
				astProp.Getter.Body = CreateMethodBody(propDef.GetMethod);
				astProp.AddAnnotation(propDef.GetMethod);
				ConvertAttributes(astProp.Getter, propDef.GetMethod);
				
				if ((getterModifiers & Modifiers.VisibilityMask) != (astProp.Modifiers & Modifiers.VisibilityMask))
					astProp.Getter.Modifiers = getterModifiers & Modifiers.VisibilityMask;
				
				astProp.Getter.WithAnnotation(methodMapping);
			}
			if (propDef.SetMethod != null) {
				// Create mapping - used in debugger
				MemberMapping methodMapping = propDef.SetMethod.CreateCodeMapping(this.CodeMappings);
				
				astProp.Setter = new Accessor();
				astProp.Setter.Body = CreateMethodBody(propDef.SetMethod);
				astProp.Setter.AddAnnotation(propDef.SetMethod);
				ConvertAttributes(astProp.Setter, propDef.SetMethod);
				ConvertCustomAttributes(astProp.Setter, propDef.SetMethod.Parameters.Last(), "param");
				
				if ((setterModifiers & Modifiers.VisibilityMask) != (astProp.Modifiers & Modifiers.VisibilityMask))
					astProp.Setter.Modifiers = setterModifiers & Modifiers.VisibilityMask;
				
				astProp.Setter.WithAnnotation(methodMapping);
			}
			ConvertCustomAttributes(astProp, propDef);
			
			if(propDef.IsIndexer())
				return ConvertPropertyToIndexer(astProp, propDef);
			else
				return astProp;
		}
开发者ID:ThomasZitzler,项目名称:ILSpy,代码行数:71,代码来源:AstBuilder.cs


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