• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# PropertyDeclaration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: VisitPropertyDeclaration

		public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
		{
			Push();
			object result = base.VisitPropertyDeclaration(propertyDeclaration, data);
			Pop();
			return result;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:PrefixFieldsVisitor.cs


示例2: VisitPropertyDeclaration

            public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
            {
                if (propertyDeclaration.Getter.Body.IsNull && propertyDeclaration.Setter.Body.IsNull)
                    UnlockWith(propertyDeclaration);

                return base.VisitPropertyDeclaration(propertyDeclaration, data);
            }
开发者ID:vlad2135,项目名称:strokes,代码行数:7,代码来源:CreateAutoPropertyAchievement.cs


示例3: EmitPropertyMethod

        protected virtual void EmitPropertyMethod(PropertyDeclaration propertyDeclaration, Accessor accessor, bool setter)
        {
            var memberResult = this.Emitter.Resolver.ResolveNode(propertyDeclaration, this.Emitter) as MemberResolveResult;

            if (memberResult != null &&
                (memberResult.Member.Attributes.Any(a => a.AttributeType.FullName == "Bridge.FieldPropertyAttribute") ||
                (propertyDeclaration.Getter.IsNull && propertyDeclaration.Setter.IsNull)))
            {
                return;
            }

            if (!accessor.IsNull && this.Emitter.GetInline(accessor) == null)
            {
                this.EnsureComma();

                this.ResetLocals();

                var prevMap = this.BuildLocalsMap();
                var prevNamesMap = this.BuildLocalsNamesMap();

                if (setter)
                {
                    this.AddLocals(new ParameterDeclaration[] { new ParameterDeclaration { Name = "value" } }, accessor.Body);
                }

                XmlToJsDoc.EmitComment(this, this.PropertyDeclaration);
                var overloads = OverloadsCollection.Create(this.Emitter, propertyDeclaration, setter);
                string name = overloads.GetOverloadName();
                this.Write((setter ? "set" : "get") + name);
                this.WriteColon();
                this.WriteFunction();
                this.WriteOpenParentheses();
                this.Write(setter ? "value" : "");
                this.WriteCloseParentheses();
                this.WriteSpace();

                var script = this.Emitter.GetScript(accessor);

                if (script == null)
                {
                    accessor.Body.AcceptVisitor(this.Emitter);
                }
                else
                {
                    this.BeginBlock();

                    foreach (var line in script)
                    {
                        this.Write(line);
                        this.WriteNewLine();
                    }

                    this.EndBlock();
                }

                this.ClearLocalsMap(prevMap);
                this.ClearLocalsNamesMap(prevNamesMap);
                this.Emitter.Comma = true;
            }
        }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:60,代码来源:VisitorPropertyBlock.cs


示例4: HandleVisitorPropertyDeclarationVisited

		void HandleVisitorPropertyDeclarationVisited (PropertyDeclaration node, InspectionData data)
		{
			foreach (var rule in policy.Rules) {
				if (rule.CheckProperty (node, data))
					return;
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:7,代码来源:NamingInspector.cs


示例5: AddRange

		/// <summary>
		/// Adds the elements of an array to the end of this PropertyDeclarationCollection.
		/// </summary>
		/// <param name="items">
		/// The array whose elements are to be added to the end of this PropertyDeclarationCollection.
		/// </param>
		public virtual void AddRange(PropertyDeclaration[] items)
		{
			foreach (PropertyDeclaration item in items)
			{
				this.List.Add(item);
			}
		}
开发者ID:uQr,项目名称:NHibernate.Mapping.Attributes,代码行数:13,代码来源:PropertyDeclarationCollection.cs


示例6: VisitPropertyDeclaration

            public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
            {
                if (propertyDeclaration.Setter.Modifiers.HasFlag(Modifiers.Private))
                {
                    UnlockWith(propertyDeclaration.Setter);
                }

                return base.VisitPropertyDeclaration(propertyDeclaration, data);
            }
开发者ID:vlad2135,项目名称:strokes,代码行数:9,代码来源:PrivateSetterAchievement.cs


示例7: PropertyReferenceExpression

        public PropertyReferenceExpression(Expression target,PropertyDeclaration property)
        {
            if (target==null)
                throw new ArgumentNullException("target");
            if (property==null)
                throw new ArgumentNullException("property");

            this.target = target;
            this.property = property;
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:10,代码来源:PropertyReferenceExpression.cs


示例8: ContainsGetter

		bool ContainsGetter (PropertyDeclaration property, VariableInitializer initializer)
		{
			if (property.Getter.IsNull || property.Getter.Body.Statements.Count () != 1)
				return false;
			var ret = property.Getter.Body.Statements.Single () as ReturnStatement;
			if (ret == null)
				return false;
			return ret.Expression.IsMatch (new IdentifierExpression (initializer.Name)) || 
				ret.Expression.IsMatch (new MemberReferenceExpression (new ThisReferenceExpression (), initializer.Name));
		}
开发者ID:tapenjoyGame,项目名称:ILSpy,代码行数:10,代码来源:GenerateGetter.cs


示例9: Create

        public static OverloadsCollection Create(IEmitter emitter, PropertyDeclaration propDeclaration, bool isSetter = false)
        {
            string key = propDeclaration.GetHashCode().ToString() + isSetter.GetHashCode().ToString();
            if (emitter.OverloadsCache.ContainsKey(key))
            {
                return emitter.OverloadsCache[key];
            }

            return new OverloadsCollection(emitter, propDeclaration, isSetter);
        }
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:10,代码来源:OverloadsCollection.cs


示例10: VisitPropertyDeclaration

 public override void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration)
 {
     if (propertyDeclaration.HasModifier(Modifiers.Static))
     {
         this.CheckDependency(propertyDeclaration.ReturnType);
         if (!propertyDeclaration.Getter.IsNull)
         {
             propertyDeclaration.Getter.AcceptVisitor(this);
         }
     }
 }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:11,代码来源:DependencyFinderVisitor.cs


示例11: CreateChangedEventDeclaration

		EventDeclaration CreateChangedEventDeclaration (RefactoringContext context, PropertyDeclaration propertyDeclaration)
		{
			return new EventDeclaration {
				Modifiers = propertyDeclaration.HasModifier (Modifiers.Static) ? Modifiers.Public | Modifiers.Static : Modifiers.Public,
				ReturnType = context.CreateShortType("System", "EventHandler"),
				Variables = {
					new VariableInitializer {
						Name = propertyDeclaration.Name + "Changed"
					}
				}
			};
		}
开发者ID:qhta,项目名称:NRefactory,代码行数:12,代码来源:CreateChangedEventAction.cs


示例12: AddPropertyGuard

        public static void AddPropertyGuard(PropertyDeclaration property, MethodBodyTransformationContext context, InstructionBlock block, InstructionWriter writer)
        {
            var propertyType = property.PropertyType;
            var methodBody = block.MethodBody;

            var sequence = block.AddInstructionSequence(null, NodePosition.After, null);
            if (sequence == null) return;

            var oldValueVariable =
                block.DefineLocalVariable(propertyType, string.Format("old{0}Value", property.Name));
            var assets = GetTransformationAssets(property.Module);

            writer.AttachInstructionSequence(sequence);
            var isLocationBinding = CheckIfIsLocationBinding(methodBody,assets);
            if (isLocationBinding) {
                writer.AssignValue_LocalVariable(oldValueVariable
                    , () => writer.Call_MethodOnTarget(property.GetGetter()
                        ,
                        () => {
                            //Load the instance parameter of the SetValue method
                            //and convert it to the type
                            writer.EmitInstruction(OpCodeNumber.Ldarg_1);
                            //writer.EmitInstructionLoadIndirect(Assets.ObjectTypeSignature);
                            writer.EmitInstructionType(OpCodeNumber.Ldobj, assets.ObjectTypeSignature);
                            writer.EmitConvertFromObject(property.Parent);
                        }
                    )
                );
                //On the location binding the value parameter is at psotion 3
                writer.EmitInstruction(OpCodeNumber.Ldarg_3);
            } else {
                writer.AssignValue_LocalVariable(oldValueVariable,
                                                    () => writer.Get_PropertyValue(property));
                //For a normal property the value parameter is at position 1
                writer.EmitInstruction(OpCodeNumber.Ldarg_1);
            }
            if (propertyType.IsStruct()) {
                writer.EmitInstructionType(OpCodeNumber.Box, propertyType);
            }
            writer.Box_LocalVariableIfNeeded(oldValueVariable);
            var isPrimitive = propertyType.IsPrimitive();
            if (isPrimitive) {
                writer.Compare_Primitives();
            } else {
                //TODO: Try and use the equality operator when present
                writer.Compare_Objects(assets.ObjectEqualsMethod);
            }
            //writer.Leave_IfTrue(_context.LeaveBranchTarget);
            writer.Leave_IfTrue(context.LeaveBranchTarget);
            writer.DetachInstructionSequence();
        }
开发者ID:DamianReeves,项目名称:PostEdge,代码行数:51,代码来源:EnhancePropertySetterMethodBodyWrappingImplementation.cs


示例13: BuildAccessorStatement

		static Statement BuildAccessorStatement (RefactoringContext context, PropertyDeclaration pdecl)
		{
			if (pdecl.Setter.IsNull && !pdecl.Getter.IsNull) {
				var field = RemoveBackingStore.ScanGetter (context, pdecl);
				if (field != null) 
					return new ExpressionStatement (new AssignmentExpression (new IdentifierExpression (field.Name), AssignmentOperatorType.Assign, new IdentifierExpression ("value")));
			}
			
			if (!pdecl.Setter.IsNull && pdecl.Getter.IsNull) {
				var field = RemoveBackingStore.ScanSetter (context, pdecl);
				if (field != null) 
					return new ReturnStatement (new IdentifierExpression (field.Name));
			}
			
			return new ThrowStatement (new ObjectCreateExpression (context.CreateShortType ("System", "NotImplementedException")));
		}
开发者ID:BGCX261,项目名称:zoom-decompiler-hg-to-git,代码行数:16,代码来源:AddAnotherAccessor.cs


示例14: GetBackingField

		internal static IField GetBackingField (BaseRefactoringContext context, PropertyDeclaration propertyDeclaration)
		{
			// automatic properties always need getter & setter
			if (propertyDeclaration == null || propertyDeclaration.Getter.IsNull || propertyDeclaration.Setter.IsNull || propertyDeclaration.Getter.Body.IsNull || propertyDeclaration.Setter.Body.IsNull)
				return null;
			if (!context.Supports(csharp3) || propertyDeclaration.HasModifier (ICSharpCode.NRefactory.CSharp.Modifiers.Abstract) || ((TypeDeclaration)propertyDeclaration.Parent).ClassType == ClassType.Interface)
				return null;
			var getterField = ScanGetter (context, propertyDeclaration);
			if (getterField == null)
				return null;
			var setterField = ScanSetter (context, propertyDeclaration);
			if (setterField == null)
				return null;
			if (!getterField.Equals(setterField))
				return null;
			return getterField;
		}
开发者ID:asiazhang,项目名称:SharpDevelop,代码行数:17,代码来源:RemoveBackingStoreAction.cs


示例15: EmitPropertyMethod

        protected virtual void EmitPropertyMethod(PropertyDeclaration propertyDeclaration, Accessor accessor, bool setter)
        {
            var memberResult = this.Emitter.Resolver.ResolveNode(propertyDeclaration, this.Emitter) as MemberResolveResult;

            if (memberResult != null &&
                (memberResult.Member.Attributes.Any(a => a.AttributeType.FullName == "Bridge.FieldPropertyAttribute") ||
                (propertyDeclaration.Getter.IsNull && propertyDeclaration.Setter.IsNull)))
            {
                return;
            }

            if (!accessor.IsNull && this.Emitter.GetInline(accessor) == null)
            {
                var p = (PropertyDeclaration)accessor.Parent;
                var overloads = OverloadsCollection.Create(this.Emitter, propertyDeclaration, setter);
                string name = overloads.GetOverloadName();
                this.Write((setter ? "set" : "get") + name);
                this.WriteOpenParentheses();
                if (setter)
                {
                    this.Write("value");
                    this.WriteColon();
                    name = BridgeTypes.ToJsName(p.ReturnType, this.Emitter);
                    name = EmitBlock.HandleType(name);
                    this.Write(name);
                }

                this.WriteCloseParentheses();
                this.WriteColon();

                if (setter)
                {
                    this.Write("void");
                }
                else
                {
                    name = BridgeTypes.ToJsName(p.ReturnType, this.Emitter);
                    name = EmitBlock.HandleType(name);
                    this.Write(name);
                }

                this.WriteSemiColon();
                this.WriteNewLine();
            }
        }
开发者ID:Oaz,项目名称:bridgedotnet_Builder,代码行数:45,代码来源:PropertyBlock.cs


示例16: GetPropertyAccessorDefinitions

        private static void GetPropertyAccessorDefinitions(PropertyDeclaration propertyDeclaration, out MethodDefDeclaration getMethodDef, out MethodDefDeclaration setMethodDef)
        {
            getMethodDef = null;
            setMethodDef = null;
            foreach (MethodSemanticDeclaration methodSemanticDef in propertyDeclaration.Members)
            {
                MethodDefDeclaration methodDef = methodSemanticDef.Method;

                if (methodDef.Name.StartsWith("get_"))
                {
                    getMethodDef = methodDef;
                }
                else if (methodDef.Name.StartsWith("set_"))
                {
                    setMethodDef = methodDef;
                }
                else
                {
                    throw new InvalidOperationException("Found a NotifyPropertyChanged attribute on something other than a property");
                }
            }
        }
开发者ID:luboshl,项目名称:propfu,代码行数:22,代码来源:NotifyPropertyChangedTask.cs


示例17: AddProperties

 public void AddProperties()
 {
     NamespaceDeclaration nsdecl = new NamespaceDeclaration("Test");
     ClassDeclaration cdecl = nsdecl.AddClass("Customer");
     FieldDeclaration lastName = new FieldDeclaration("_lastName", "System.String");
     PropertyDeclaration propdecl = new PropertyDeclaration("LastName", lastName, typeof(string));
     cdecl.AddProperty(propdecl);
     PropertyDeclaration firstName = cdecl.AddProperty("FirstName", "_firstName", typeof(string));
     PropertyDeclaration duplicateFirstName = cdecl.AddProperty("FirstName", "_firstName", typeof(string));
     Assert.AreEqual(firstName, duplicateFirstName);
     cdecl.AddProperty("DateOfBirth", "_dateOfBirth", typeof(DateTime), true);
     cdecl.AddProperty("Age", "_age", new CodeDomTypeReference(typeof(int)));
     cdecl.AddProperty("Items", "_items", "System.Collections.Generic.List", "System.String");
     using (DomTester dom = new DomTester(nsdecl))
     {
         Assert.IsTrue(dom.ContainsType("Test.Customer"));
         Assert.IsTrue(dom.ContainsProperty("Test.Customer", "FirstName"));
         Assert.IsTrue(dom.ContainsProperty("Test.Customer", "LastName"));
         Assert.IsTrue(dom.ContainsProperty("Test.Customer", "DateOfBirth"));
         Assert.IsTrue(dom.ContainsProperty("Test.Customer", "Age"));
         Assert.IsTrue(dom.ContainsProperty("Test.Customer", "Items"));
     }
     new CodeBuilder().GenerateCode(Console.Out, nsdecl);
 }
开发者ID:chrcar01,项目名称:HyperActive,代码行数:24,代码来源:ClassDeclarationTests.cs


示例18: Parse

		public static CSProperty Parse(PropertyDeclaration propertyNode)
		{
			CSProperty returnValue = new CSProperty();
			returnValue.ProtectionLevel = EnumProtectionLevel.Private;
			if ((propertyNode.Modifiers & Modifiers.Public) == Modifiers.Public)
			{
				returnValue.ProtectionLevel = EnumProtectionLevel.Public;
			}
			else if ((propertyNode.Modifiers & Modifiers.Private) == Modifiers.Private)
			{
				returnValue.ProtectionLevel = EnumProtectionLevel.Private;
			}
			else if ((propertyNode.Modifiers & Modifiers.Protected) == Modifiers.Protected)
			{
				returnValue.ProtectionLevel = EnumProtectionLevel.Protected;
			}
			else if ((propertyNode.Modifiers & Modifiers.Internal) == Modifiers.Internal)
			{
				returnValue.ProtectionLevel = EnumProtectionLevel.Internal;
			}
			string typeName;
			string typeNamespace;
			DotNetParserHelper.SplitType(propertyNode.ReturnType.ToString(), out typeName, out typeNamespace);
			returnValue.TypeName = typeName;
			returnValue.TypeNamespace = typeNamespace;
			returnValue.PropertyName = propertyNode.Name;
			foreach (var attributeSectionNode in propertyNode.Attributes)
			{
				foreach (var attributeNode in attributeSectionNode.Attributes)
				{
					var attribute = CSAttribute.Parse(attributeNode);
					returnValue.AttributeList.Add(attribute);
				}
			}
			return returnValue;
		}
开发者ID:mmooney,项目名称:MMDB.UITest,代码行数:36,代码来源:CSProperty.cs


示例19: ScanGetter

		internal static IField ScanGetter (RefactoringContext context, PropertyDeclaration propertyDeclaration)
		{
			if (propertyDeclaration.Getter.Body.Statements.Count != 1)
				return null;
			var returnStatement = propertyDeclaration.Getter.Body.Statements.First () as ReturnStatement;
			if (returnStatement == null)
				return null;
			var result = context.Resolve (returnStatement.Expression);
			if (result == null || !(result is MemberResolveResult))
				return null;
			return ((MemberResolveResult)result).Member as IField;
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:12,代码来源:RemoveBackingStoreAction.cs


示例20: VisitPropertyDeclaration

		public void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration)
		{
			StartNode(propertyDeclaration);
			WriteAttributes(propertyDeclaration.Attributes);
			WriteModifiers(propertyDeclaration.ModifierTokens);
			propertyDeclaration.ReturnType.AcceptVisitor(this);
			Space();
			WritePrivateImplementationType(propertyDeclaration.PrivateImplementationType);
			propertyDeclaration.NameToken.AcceptVisitor(this);
			OpenBrace(policy.PropertyBraceStyle);
			// output get/set in their original order
			foreach (AstNode node in propertyDeclaration.Children) {
				if (node.Role == IndexerDeclaration.GetterRole || node.Role == IndexerDeclaration.SetterRole) {
					node.AcceptVisitor(this);
				}
			}
			CloseBrace(policy.PropertyBraceStyle);
			NewLine();
			EndNode(propertyDeclaration);
		}
开发者ID:x-strong,项目名称:ILSpy,代码行数:20,代码来源:CSharpOutputVisitor.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PropertyDefinition类代码示例发布时间:2022-05-24
下一篇:
C# PropertyData类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap