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


C# MethodDeclaration.HasModifier方法代码示例

本文整理汇总了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;
 }
开发者ID:GavinHwa,项目名称:Bridge,代码行数:13,代码来源:OverloadsCollection.cs

示例2: VisitMethodDeclaration

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

示例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);
            }
开发者ID:clausjoergensen,项目名称:strokes,代码行数:13,代码来源:DeclareMethod.cs

示例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);
            }
开发者ID:vlad2135,项目名称:strokes,代码行数:17,代码来源:SingleLineMethod.cs

示例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}));
            }
        }
开发者ID:Oaz,项目名称:bridgedotnet_Builder,代码行数:26,代码来源:Inspector.Visitor.cs

示例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);
//.........这里部分代码省略.........
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:101,代码来源:VisitorMethodBlock.cs

示例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)
//.........这里部分代码省略.........
开发者ID:wangxueqzz,项目名称:Bridge,代码行数:101,代码来源:VisitorMethodBlock.cs

示例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);
            }
开发者ID:cohenw,项目名称:strokes,代码行数:17,代码来源:CreateMethodReturnTypeX.cs

示例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;
        }
开发者ID:txdv,项目名称:Builder,代码行数:76,代码来源:VisitorMethodBlock.cs


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