本文整理汇总了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;
}
示例2: VisitFieldDeclaration
public override void VisitFieldDeclaration(FieldDeclaration fieldDeclaration)
{
if (fieldDeclaration.HasModifier(Modifiers.Static))
{
this.CheckDependency(fieldDeclaration.ReturnType);
base.VisitFieldDeclaration(fieldDeclaration);
}
}
示例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))
}
}
};
}
示例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)));
}
}
示例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")))
}
}
};
}
示例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
});
}
}
}
示例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
});
}
}
}