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


C# FieldDeclaration.HasModifier方法代码示例

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


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

示例1: OverloadsCollection

 private OverloadsCollection(IEmitter emitter, FieldDeclaration fieldDeclaration)
 {
     this.Emitter = emitter;
     this.Name = emitter.GetFieldName(fieldDeclaration);
     this.JsName = this.Emitter.GetEntityName(fieldDeclaration, false, true);
     this.Inherit = !fieldDeclaration.HasModifier(Modifiers.Static);
     this.Static = fieldDeclaration.HasModifier(Modifiers.Static);
     this.Member = this.FindMember(fieldDeclaration);
     this.TypeDefinition = this.Member.DeclaringTypeDefinition;
     this.Type = this.Member.DeclaringType;
     this.InitMembers();
     this.Emitter.OverloadsCache[fieldDeclaration.GetHashCode().ToString()] = this;
 }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:13,代码来源:OverloadsCollection.cs

示例2: VisitFieldDeclaration

 public override void VisitFieldDeclaration(FieldDeclaration fieldDeclaration)
 {
     if (fieldDeclaration.HasModifier(Modifiers.Static))
     {
         this.CheckDependency(fieldDeclaration.ReturnType);
         base.VisitFieldDeclaration(fieldDeclaration);
     }
 }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:8,代码来源:DependencyFinderVisitor.cs

示例3: GeneratePropertyDeclaration

		static PropertyDeclaration GeneratePropertyDeclaration (RefactoringContext context, FieldDeclaration field, VariableInitializer initializer)
		{
			var mod = ICSharpCode.NRefactory.CSharp.Modifiers.Public;
			if (field.HasModifier (ICSharpCode.NRefactory.CSharp.Modifiers.Static))
				mod |= ICSharpCode.NRefactory.CSharp.Modifiers.Static;
			
			return new PropertyDeclaration () {
				Modifiers = mod,
				Name = context.GetNameProposal (initializer.Name, false),
				ReturnType = field.ReturnType.Clone (),
				Getter = new Accessor () {
					Body = new BlockStatement () {
						new ReturnStatement (new IdentifierExpression (initializer.Name))
					}
				}
			};
		}
开发者ID:tapenjoyGame,项目名称:ILSpy,代码行数:17,代码来源:GenerateGetter.cs

示例4: VisitFieldDeclaration

            public override void VisitFieldDeclaration(FieldDeclaration fieldDeclaration)
            {
                base.VisitFieldDeclaration (fieldDeclaration);
                if (fieldDeclaration.HasModifier (Modifiers.Const))
                    return;
                var defaultValueExpr = GetDefaultValueExpression (fieldDeclaration.ReturnType);
                if (defaultValueExpr == null)
                    return;

                foreach (var variable1 in fieldDeclaration.Variables) {
                    var variable = variable1;
                    if (!defaultValueExpr.Match (variable.Initializer).Success)
                        continue;

                    AddIssue (variable.Initializer, ctx.TranslateString ("Remove redundant field initializer"),
                        script => script.Replace (variable, new VariableInitializer (variable.Name)));
                }
            }
开发者ID:artifexor,项目名称:NRefactory,代码行数:18,代码来源:RedundantFieldInitializerIssue.cs

示例5: GeneratePropertyDeclaration

		static PropertyDeclaration GeneratePropertyDeclaration (RefactoringContext context, FieldDeclaration field, string fieldName)
		{
			var mod = ICSharpCode.NRefactory.CSharp.Modifiers.Public;
			if (field.HasModifier (ICSharpCode.NRefactory.CSharp.Modifiers.Static))
				mod |= ICSharpCode.NRefactory.CSharp.Modifiers.Static;
			
			return new PropertyDeclaration () {
				Modifiers = mod,
				Name = context.GetNameProposal (fieldName, false),
				ReturnType = field.ReturnType.Clone (),
				Getter = new Accessor () {
					Body = new BlockStatement () {
						new ReturnStatement (new IdentifierExpression (fieldName))
					}
				},
				Setter = new Accessor () {
					Body = new BlockStatement () {
						new ExpressionStatement (new AssignmentExpression (new IdentifierExpression (fieldName), new IdentifierExpression ("value")))
					}
				}
			};
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:22,代码来源:GeneratePropertyAction.cs

示例6: VisitFieldDeclaration

        public override void VisitFieldDeclaration(FieldDeclaration fieldDeclaration)
        {
            bool isStatic = this.CurrentType.ClassType == ClassType.Enum
                || fieldDeclaration.HasModifier(Modifiers.Static)
                || fieldDeclaration.HasModifier(Modifiers.Const);

            foreach (var item in fieldDeclaration.Variables)
            {
                Expression initializer = item.Initializer;

                if (initializer.IsNull)
                {
                    if (this.CurrentType.ClassType == ClassType.Enum)
                    {
                        throw (Exception)this.CreateException(fieldDeclaration, "Enum items must be explicitly numbered");
                    }

                    initializer = this.GetDefaultFieldInitializer(fieldDeclaration.ReturnType);
                }

                this.CurrentType.FieldsDeclarations.Add(item.Name, fieldDeclaration);

                if (isStatic)
                {
                    this.CurrentType.StaticConfig.Fields.Add(new TypeConfigItem
                    {
                        Name = item.Name,
                        Entity = fieldDeclaration,
                        IsConst = fieldDeclaration.HasModifier(Modifiers.Const),
                        VarInitializer = item,
                        Initializer = initializer
                    });
                    }
                    else
                    {
                    this.CurrentType.InstanceConfig.Fields.Add(new TypeConfigItem
                {
                        Name = item.Name,
                        Entity = fieldDeclaration,
                        VarInitializer = item,
                        Initializer = initializer
                    });
                }
            }
        }
开发者ID:Oaz,项目名称:bridgedotnet_Builder,代码行数:45,代码来源:Inspector.Visitor.cs

示例7: VisitFieldDeclaration

        public override void VisitFieldDeclaration(FieldDeclaration fieldDeclaration)
        {
            bool isStatic = this.CurrentType.ClassType == ClassType.Enum
                || fieldDeclaration.HasModifier(Modifiers.Static)
                || fieldDeclaration.HasModifier(Modifiers.Const);

            foreach (var item in fieldDeclaration.Variables)
            {
                var rr = this.Resolver.ResolveNode(item, null) as MemberResolveResult;
                if (fieldDeclaration.HasModifier(Modifiers.Const) && rr != null && rr.Member.Attributes.Any(a => a.AttributeType.FullName == Bridge.Translator.Translator.Bridge_ASSEMBLY + ".InlineConstAttribute"))
                {
                    continue;
                }

                Expression initializer = item.Initializer;

                if (initializer.IsNull)
                {
                    if (this.CurrentType.ClassType == ClassType.Enum)
                    {
                        throw (EmitterException)this.CreateException(fieldDeclaration, "Enum items must be explicitly numbered");
                    }

                    initializer = this.GetDefaultFieldInitializer(fieldDeclaration.ReturnType);
                }

                this.CurrentType.FieldsDeclarations.Add(item.Name, fieldDeclaration);

                if (isStatic)
                {
                    this.CurrentType.StaticConfig.Fields.Add(new TypeConfigItem
                    {
                        Name = item.Name,
                        Entity = fieldDeclaration,
                        IsConst = fieldDeclaration.HasModifier(Modifiers.Const),
                        VarInitializer = item,
                        Initializer = initializer
                    });
                }
                else
                {
                    this.CurrentType.InstanceConfig.Fields.Add(new TypeConfigItem
                    {
                        Name = item.Name,
                        Entity = fieldDeclaration,
                        VarInitializer = item,
                        Initializer = initializer
                    });
                }
            }
        }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:51,代码来源:Inspector.Visitor.cs


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