本文整理汇总了C#中MethodDeclaration.HasModifier方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDeclaration.HasModifier方法的具体用法?C# MethodDeclaration.HasModifier怎么用?C# MethodDeclaration.HasModifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MethodDeclaration
的用法示例。
在下文中一共展示了MethodDeclaration.HasModifier方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OverloadsCollection
private OverloadsCollection(IEmitter emitter, MethodDeclaration methodDeclaration)
{
this.Emitter = emitter;
this.Name = methodDeclaration.Name;
this.JsName = this.Emitter.GetEntityName(methodDeclaration, false, true);
this.Inherit = !methodDeclaration.HasModifier(Modifiers.Static);
this.Static = methodDeclaration.HasModifier(Modifiers.Static);
this.Member = this.FindMember(methodDeclaration);
this.TypeDefinition = this.Member.DeclaringTypeDefinition;
this.Type = this.Member.DeclaringType;
this.InitMembers();
this.Emitter.OverloadsCache[methodDeclaration.GetHashCode().ToString()] = this;
}
示例2: VisitMethodDeclaration
public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
{
if (methodDeclaration.HasModifier(Modifiers.Static))
{
this.CheckDependency(methodDeclaration.ReturnType);
base.VisitMethodDeclaration(methodDeclaration);
}
}
示例3: VisitMethodDeclaration
public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
{
if (methodDeclaration.Name.ToLower().Equals("main") == false)
{
if (methodDeclaration.IsExtensionMethod == false &&
methodDeclaration.HasModifier(Modifiers.Abstract) == false)
{
UnlockWith(methodDeclaration);
}
}
return base.VisitMethodDeclaration(methodDeclaration, data);
}
示例4: VisitMethodDeclaration
public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
{
if (!methodDeclaration.Name.ToLower().Equals("main"))
{
if (!methodDeclaration.IsExtensionMethod &&
!methodDeclaration.HasModifier(Modifiers.Abstract))
{
if (methodDeclaration.Body.Statements.Count() == 1 &&
methodDeclaration.Body.Statements.First() is ReturnStatement)
{
UnlockWith(methodDeclaration);
}
}
}
return base.VisitMethodDeclaration(methodDeclaration, data);
}
示例5: VisitMethodDeclaration
public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
{
if (methodDeclaration.HasModifier(Modifiers.Abstract) || this.HasInline(methodDeclaration))
{
return;
}
this.FixMethodParameters(methodDeclaration.Parameters, methodDeclaration.Body);
bool isStatic = methodDeclaration.HasModifier(Modifiers.Static);
Dictionary<string, List<MethodDeclaration>> dict = isStatic
? CurrentType.StaticMethods
: CurrentType.InstanceMethods;
var key = methodDeclaration.Name;
if (dict.ContainsKey(key))
{
dict[key].Add(methodDeclaration);
}
else
{
dict.Add(key, new List<MethodDeclaration>(new []{methodDeclaration}));
}
}
示例6: VisitMethodDeclaration
protected void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
{
foreach (var attrSection in methodDeclaration.Attributes)
{
foreach (var attr in attrSection.Attributes)
{
var rr = this.Emitter.Resolver.ResolveNode(attr.Type, this.Emitter);
if (rr.Type.FullName == "Bridge.ExternalAttribute" || rr.Type.FullName == "Bridge.IgnoreAttribute")
{
return;
}
else if (rr.Type.FullName == "Bridge.InitAttribute")
{
int initPosition = 0;
if (attr.HasArgumentList)
{
if (attr.Arguments.Any())
{
var argExpr = attr.Arguments.First();
var argrr = this.Emitter.Resolver.ResolveNode(argExpr, this.Emitter);
if (argrr.ConstantValue is int)
{
initPosition = (int)argrr.ConstantValue;
}
}
}
if (initPosition > 0)
{
return;
}
}
}
}
//this.EnsureComma();
this.EnsureNewLine();
this.ResetLocals();
var prevMap = this.BuildLocalsMap();
var prevNamesMap = this.BuildLocalsNamesMap();
this.AddLocals(methodDeclaration.Parameters, methodDeclaration.Body);
var typeDef = this.Emitter.GetTypeDefinition();
var overloads = OverloadsCollection.Create(this.Emitter, methodDeclaration);
XmlToJsDoc.EmitComment(this, this.MethodDeclaration);
string name = overloads.GetOverloadName();
TransformCtx.CurClassMethodNames.Add(new TransformCtx.MethodInfo() {
Name = name,
IsPrivate = methodDeclaration.HasModifier(Modifiers.Private),
});
this.Write(name);
this.WriteEqualsSign();
/*
if (methodDeclaration.TypeParameters.Count > 0)
{
this.WriteFunction();
this.EmitTypeParameters(methodDeclaration.TypeParameters, methodDeclaration);
this.WriteSpace();
this.BeginBlock();
this.WriteReturn(true);
this.Write("Bridge.fn.bind(this, ");
}*/
this.WriteFunction();
this.EmitMethodParameters(methodDeclaration.Parameters, methodDeclaration, true);
if(methodDeclaration.TypeParameters.Count > 0) {
if(methodDeclaration.Parameters.Count > 0 || !methodDeclaration.HasModifier(Modifiers.Static)) {
this.WriteComma();
}
this.EmitTypeParameters(methodDeclaration.TypeParameters, methodDeclaration);
}
this.WriteCloseParentheses();
this.WriteSpace();
var script = this.Emitter.GetScript(methodDeclaration);
if (script == null)
{
if (methodDeclaration.HasModifier(Modifiers.Async))
{
new AsyncBlock(this.Emitter, methodDeclaration).Emit();
}
else
{
this.BeginFunctionBlock();
methodDeclaration.Body.AcceptVisitor(this.Emitter);
PrimitiveType returnType = methodDeclaration.ReturnType as PrimitiveType;
if(returnType != null) {
if(returnType.KnownTypeCode == ICSharpCode.NRefactory.TypeSystem.KnownTypeCode.Void) {
string refArgsString = GetRefArgsString(this.Emitter, methodDeclaration);
if(refArgsString != null) {
this.WriteReturn(true);
//.........这里部分代码省略.........
示例7: VisitMethodDeclaration
protected void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
{
foreach (var attrSection in methodDeclaration.Attributes)
{
foreach (var attr in attrSection.Attributes)
{
var rr = this.Emitter.Resolver.ResolveNode(attr.Type, this.Emitter);
if (rr.Type.FullName == "Bridge.InitAttribute")
{
int initPosition = 0;
if (attr.HasArgumentList)
{
if (attr.Arguments.Any())
{
var argExpr = attr.Arguments.First();
var argrr = this.Emitter.Resolver.ResolveNode(argExpr, this.Emitter);
if (argrr.ConstantValue is int)
{
initPosition = (int)argrr.ConstantValue;
}
}
}
if (initPosition == 1) // Before
{
return;
}
}
}
}
this.EnsureComma();
this.ResetLocals();
var prevMap = this.BuildLocalsMap();
var prevNamesMap = this.BuildLocalsNamesMap();
this.AddLocals(methodDeclaration.Parameters, methodDeclaration.Body);
var typeDef = this.Emitter.GetTypeDefinition();
var overloads = OverloadsCollection.Create(this.Emitter, methodDeclaration);
XmlToJsDoc.EmitComment(this, this.MethodDeclaration);
if (overloads.HasOverloads)
{
string name = overloads.GetOverloadName();
this.Write(name);
}
else
{
this.Write(this.Emitter.GetEntityName(methodDeclaration));
}
this.WriteColon();
if (methodDeclaration.TypeParameters.Count > 0)
{
this.WriteFunction();
this.EmitTypeParameters(methodDeclaration.TypeParameters, methodDeclaration);
this.WriteSpace();
this.BeginBlock();
this.WriteReturn(true);
this.Write("Bridge.fn.bind(this, ");
}
this.WriteFunction();
this.EmitMethodParameters(methodDeclaration.Parameters, methodDeclaration);
this.WriteSpace();
var script = this.Emitter.GetScript(methodDeclaration);
if (script == null)
{
if (methodDeclaration.HasModifier(Modifiers.Async))
{
new AsyncBlock(this.Emitter, methodDeclaration).Emit();
}
else
{
methodDeclaration.Body.AcceptVisitor(this.Emitter);
}
}
else
{
this.BeginBlock();
foreach (var line in script)
{
this.Write(line);
this.WriteNewLine();
}
this.EndBlock();
}
if (methodDeclaration.TypeParameters.Count > 0)
//.........这里部分代码省略.........
示例8: VisitMethodDeclaration
public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
{
if(IsAchievementUnlocked) //Actually, all achievements should do this - it would improve performance and heaping a bit
return base.VisitMethodDeclaration(methodDeclaration, data);
if (!methodDeclaration.Name.ToLower().Equals("main"))
{
if (!methodDeclaration.IsExtensionMethod && !methodDeclaration.HasModifier(Modifiers.Abstract))
{
var returnType = methodDeclaration.ReturnType as PrimitiveType;
if (returnType != null && returnType.ToString() == "void")
UnlockWith(methodDeclaration);
}
}
return base.VisitMethodDeclaration(methodDeclaration, data);
}
示例9: VisitMethodDeclaration
protected void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
{
this.EnsureComma();
this.ResetLocals();
var prevMap = this.BuildLocalsMap();
var prevNamesMap = this.BuildLocalsNamesMap();
this.AddLocals(methodDeclaration.Parameters, methodDeclaration.Body);
var typeDef = this.Emitter.GetTypeDefinition();
var overloads = OverloadsCollection.Create(this.Emitter, methodDeclaration);
if (overloads.HasOverloads)
{
string name = overloads.GetOverloadName();
this.Write(name);
}
else
{
this.Write(this.Emitter.GetEntityName(methodDeclaration));
}
this.WriteColon();
if (methodDeclaration.TypeParameters.Count > 0)
{
this.WriteFunction();
this.EmitTypeParameters(methodDeclaration.TypeParameters, methodDeclaration);
this.WriteSpace();
this.BeginBlock();
this.WriteReturn(true);
}
this.WriteFunction();
this.EmitMethodParameters(methodDeclaration.Parameters, methodDeclaration);
this.WriteSpace();
var script = this.Emitter.GetScript(methodDeclaration);
if (script == null)
{
if (methodDeclaration.HasModifier(Modifiers.Async))
{
new AsyncBlock(this.Emitter, methodDeclaration).Emit();
}
else
{
methodDeclaration.Body.AcceptVisitor(this.Emitter);
}
}
else
{
this.BeginBlock();
foreach (var line in script)
{
this.Write(line);
this.WriteNewLine();
}
this.EndBlock();
}
if (methodDeclaration.TypeParameters.Count > 0)
{
this.WriteNewLine();
this.EndBlock();
}
this.ClearLocalsMap(prevMap);
this.ClearLocalsNamesMap(prevNamesMap);
this.Emitter.Comma = true;
}