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


C# PropertyDeclaration类代码示例

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


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


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