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


C# IMethod.ToString方法代码示例

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


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

示例1: GetMethodWithCustomBodyOrDefault

        public static IMethod GetMethodWithCustomBodyOrDefault(IMethod method, ITypeResolver typeResolver)
        {
            if (MethodsByFullName.Count == 0)
            {
                lock (Locker)
                {
                    // we double check to filter threads waiting on 'lock'
                    if (MethodsByFullName.Count == 0)
                    {
                        RegisterAll(typeResolver);
                    }
                }
            }

            Func<IMethod, IMethod> methodFactory;
            if (MethodsByFullName.TryGetValue(method.ToString(), out methodFactory))
            {
                var newMethod = methodFactory.Invoke(method);
                if (newMethod != null)
                {
                    return newMethod;
                }
            }

            // dynamiclly generated method for MulticastDelegate
            if (method.IsDelegateFunctionBody()
                && (method.Name == "Invoke")
                && (method.DeclaringType.BaseType.FullName == "System.MulticastDelegate"))
            {
                byte[] code;
                IList<object> tokenResolutions;
                IList<IType> locals;
                IList<IParameter> parameters;
                DelegateGen.GetMulticastDelegateInvoke(
                    method,
                    typeResolver,
                    out code,
                    out tokenResolutions,
                    out locals,
                    out parameters);
                return GetMethodDecorator(method, code, tokenResolutions, locals, parameters);
            }

            return method;
        }
开发者ID:afrog33k,项目名称:csnative,代码行数:45,代码来源:MethodBodyBank.cs

示例2: GetMethodBodyOrDefault

        public static IMethod GetMethodBodyOrDefault(IMethod method, ICodeWriter codeWriter)
        {
            if (methodsByFullName.Count == 0)
            {
                RegisterAll(codeWriter);
            }

            Func<IMethod, IMethod> methodFactory;
            if (methodsByFullName.TryGetValue(method.ToString(), out methodFactory))
            {
                var newMethod = methodFactory.Invoke(method);
                if (newMethod != null)
                {
                    return newMethod;
                }
            }

            return method;
        }
开发者ID:SperoSophia,项目名称:il2bc,代码行数:19,代码来源:MethodBodyBank.cs

示例3: CheckConditionalAttributes

 //returns true if no conditional attribute match the defined symbols
 //else return false (which means the method won't get emitted)
 private bool CheckConditionalAttributes(IMethod method)
 {
     foreach (string conditionalSymbol in GetConditionalSymbols(method))
         if (!Parameters.Defines.ContainsKey(conditionalSymbol))
         {
             _context.TraceInfo("call to method '{0}' not emitted because the symbol '{1}' is not defined.", method.ToString(), conditionalSymbol);
             return false;
         }
     return true;
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:12,代码来源:EmitAssembly.cs

示例4: MethodHidesInheritedNonVirtual

 private void MethodHidesInheritedNonVirtual(InternalMethod hidingMethod, IMethod hiddenMethod)
 {
     Warnings.Add(CompilerWarningFactory.MethodHidesInheritedNonVirtual(hidingMethod.Method, hidingMethod.ToString(), hiddenMethod.ToString()));
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:4,代码来源:ProcessMethodBodies.cs

示例5: CantOverrideNonVirtual

 void CantOverrideNonVirtual(Method method, IMethod baseMethod)
 {
     Error(CompilerErrorFactory.CantOverrideNonVirtual(method, baseMethod.ToString()));
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:4,代码来源:ProcessMethodBodies.cs

示例6: regenMovedSymbolsMethod

        private void regenMovedSymbolsMethod(IMethod method, SymbolWriterClass emitter)
        {
            MethodDefinition targtMet, targtMetOld;

            // Find appropriete new version of method in new assembly.
            targtMet = MetadataManager.FindMethod(ResourceManager.NewAssembly,
                                                          ResourceManager.NewAssemblyName, method);
            if (targtMet == null) throw new TranslatingException("Method "+method.ToString()+" could not be found in debugged module");

            // Find appropriete original version of method in running assembly.
            targtMetOld = MetadataManager.FindMethod(ResourceManager.OldAssembly,
                                                             ResourceManager.CurrentModule.Name, method);
            if (targtMetOld == null) throw new TranslatingException("Method " + method.ToString() + " could not be found in emitted module");

            emitter.EmitMethod(targtMetOld.MetadataToken.ToUInt32(), targtMet.MetadataToken.ToUInt32());
        }
开发者ID:maresja1,项目名称:SDenc,代码行数:16,代码来源:EnCManager.cs

示例7: CheckConditionalAttributes

        //returns true if no conditional attribute match the defined symbols
        //else return false (which means the method won't get emitted)
        private bool CheckConditionalAttributes(IMethod method, MethodInfo mi)
        {
            if (method.ReturnType != TypeSystemServices.VoidType
                || null != (method as GenericMappedMethod)) return true;

            object[] attrs;

            if (null != (method as InternalMethod) || (null != (method as GenericConstructedMethod) &&
             				null == (((GenericConstructedMethod)method).GenericDefinition as ExternalMethod)))
            {

                //internal methods
                InternalMethod im = (method as InternalMethod) ?? ((method as GenericConstructedMethod).GenericDefinition as InternalMethod);
                attrs = MetadataUtil.GetCustomAttributes(im.Method, TypeSystemServices.ConditionalAttribute);

                if (0 == attrs.Length) return true;
                foreach (Boo.Lang.Compiler.Ast.Attribute attr in attrs)
                {
                    if (1 != attr.Arguments.Count || null == (attr.Arguments[0] as StringLiteralExpression)) continue;
                    string conditionString = (attr.Arguments[0] as StringLiteralExpression).Value;
                    if (!Parameters.Defines.ContainsKey(conditionString)) {
                        _context.TraceInfo("call to method '{0}' not emitted because the symbol '{1}' is not defined.", method.ToString(), conditionString);
                        return false;
                    }
                }

            } else {

                //external methods
                attrs = mi.GetCustomAttributes(typeof(System.Diagnostics.ConditionalAttribute), false);
                if (0 == attrs.Length) return true;
                foreach (System.Diagnostics.ConditionalAttribute attr in attrs)
                {
                    if (!Parameters.Defines.ContainsKey(attr.ConditionString)) {
                        _context.TraceInfo("call to method '{0}' not emitted because the symbol '{1}' is not defined.", method.ToString(), attr.ConditionString);
                        return false;
                    }
                }

            }

            return true;
        }
开发者ID:w4x,项目名称:boolangstudio,代码行数:45,代码来源:EmitAssembly.cs

示例8: ExportMethodBody

 protected JsBlock ExportMethodBody(IMethod me)
 {
     if (CompilerConfiguration.Current.EnableLogging)
     {
         Log.Debug("JsTypeImporter: Visit Method: " + me.ToString());
     }
     var nativeCode = Sk.GetNativeCode(me);
     if (nativeCode != null)
     {
         var block = Js.Block().Add(Js.CodeStatement(nativeCode)); //TODO: double semicolon?
         return block;
     }
     var def = me.GetDefinition();
     if (def == null || def.IsNull)
     {
         if (me.IsAutomaticEventAccessor())
         {
             if (me.IsEventAddAccessor())
             {
                 var node = GenerateAutomaticEventAccessor((IEvent)me.GetOwner(), false);
                 return node.Block;
             }
             else if (me.IsEventRemoveAccessor())
             {
                 var node = GenerateAutomaticEventAccessor((IEvent)me.GetOwner(), true);
                 return node.Block;
             }
         }
         else if (me.IsAutomaticPropertyAccessor())
         {
             var bf = Js.Member("_" + SkJs.GetEntityJsName(me.AccessorOwner));
             if (!me.IsStatic)
                 bf.PreviousMember = Js.This();
             else if (!Sk.IsGlobalMethod(me))
                 bf.PreviousMember = SkJs.EntityToMember(me.DeclaringTypeDefinition);
             if (me.IsGetter())
                 return Js.Block().Add(Js.Return(bf));
             else
                 return Js.Block().Add(bf.Assign(Js.Member("value")).Statement());
         }
         return null;
     }
     var block2 = (JsBlock)AstNodeConverter.Visit(def);
     if (def.Descendants.OfType<YieldReturnStatement>().FirstOrDefault() != null)
     {
         if (!AstNodeConverter.SupportClrYield)
         {
             if (block2.Statements == null)
                 block2.Statements = new List<JsStatement>();
             block2.Statements.Insert(0, Js.Var("$yield", Js.NewJsonArray()).Statement());
             block2.Statements.Add(AstNodeConverter.GenerateYieldReturnStatement(me));
         }
     }
     return block2;
 }
开发者ID:benbon,项目名称:SharpKit,代码行数:55,代码来源:MemberConverter.cs

示例9: MethodKey

 public MethodKey(IMethod method, IType ownerOfExplicitInterface)
 {
     this._key = method.ToString(ownerOfExplicitInterface);
     this.Method = method;
     this.OwnerOfExplicitInterface = ownerOfExplicitInterface;
 }
开发者ID:afrog33k,项目名称:csnative,代码行数:6,代码来源:MethodKey.cs

示例10: PreAddMethod

        /// <summary>
        /// Add method to metadata, but not to IL code stream. Used for upcoming search for metadata token.
        /// </summary>
        /// <param name="method">Interface describing method.</param>
        public void PreAddMethod(IMethod method)
        {
            MethodDefinition targtMet;

            targtMet = Manager.MetadataManager.FindMethod(Manager.ResourceManager.NewAssembly,
                                                          Manager.ResourceManager.NewAssemblyName, method);
            if (targtMet == null) throw new TranslatingException("Method " + method.ToString() + " could not be found in emitted module");

            MethodTranslator translator = new MethodTranslator(this);
            MethodDescriptor log = translator.TranslateMethodWithoutBody(targtMet);
            Manager.MetadataManager.RegisterNewMethod(targtMet.MetadataToken, new MetadataToken(log.destToken));

            newMethods.Add(targtMet.MetadataToken.ToUInt32(), targtMet);
        }
开发者ID:maresja1,项目名称:SDenc,代码行数:18,代码来源:DeltaBuilder.cs

示例11: ChangeMethod

        /// <summary>
        /// Changes method IL and method metadata.
        /// </summary>
        /// <param name="method">Method to be changed by EnC.</param>
        public void ChangeMethod(IMethod method)
        {
            // Method RVA is offset to start of byte buffer
            uint RVA = (uint)dIL.Count + 4;

            MethodDefinition targtMet, targtMetOld;

            // Find appropriete new version of method in new assembly.
            targtMet = Manager.MetadataManager.FindMethod(Manager.ResourceManager.NewAssembly,
                                                          Manager.ResourceManager.NewAssemblyName, method);
            if (targtMet == null) throw new TranslatingException("Method " + method.ToString() + " could not be found in emitted module");

            // Find appropriete original version of method in running assembly.
            targtMetOld = Manager.MetadataManager.FindMethod(Manager.ResourceManager.OldAssembly,
                                                             Manager.ResourceManager.CurrentModule.Name, method);
            if (targtMetOld == null) throw new TranslatingException("Method " + method.ToString() + " could not be found in debugged module");

            // Get SequencePointRemapper for method (needed to diff local definitions)
            SequencePointRemapper remapper = genSequencePointRemapper(targtMetOld, targtMet);
            // Translate tokens in methods IL code.
            MethodTranslator translator = new MethodTranslator(this);

            Dictionary<int, int> placeholder;
            MethodDescriptor log = translator.TranslateMethod(targtMet, targtMetOld, remapper, out placeholder);
            log.newRva = RVA;

            // Set method RVA.
            Manager.MetadataManager.OldEmitter.CorMetaDataEmit.SetRVA(targtMetOld.MetadataToken.ToUInt32(), RVA);

            // Store methods IL to buffer
            dIL.AddRange(log.codeIL);
            if (SymbolWriter != null) {
                SymbolWriter.EmitMethod(log.destToken, log.srcToken, placeholder);
            }
        }
开发者ID:maresja1,项目名称:SDenc,代码行数:39,代码来源:DeltaBuilder.cs

示例12: AddMethod

        /// <summary>
        /// Adds new method to IL code stream and metadata.
        /// </summary>
        /// <param name="method">Interface describing method.</param>
        public void AddMethod(IMethod method)
        {
            uint RVA = (uint)dIL.Count + 4;

            MethodDefinition targtMet, emittedMehtod;

            targtMet = Manager.MetadataManager.FindMethod(Manager.ResourceManager.NewAssembly,
                                                          Manager.ResourceManager.NewAssemblyName, method);
            if (targtMet == null) throw new TranslatingException("Method " + method.ToString() + " could not be found in emitted module");

            MethodTranslator translator = new MethodTranslator(this);
            MethodDescriptor log = translator.TranslateNewMethod(targtMet, out emittedMehtod);

            Manager.MetadataManager.OldEmitter.CorMetaDataEmit.SetRVA(log.destToken, RVA);

            TypeDefinition typeDef = Manager.MetadataManager.FindTypeDefinition(Manager.ResourceManager.OldAssembly,
                                                                                Manager.ResourceManager.CurrentModule.Name, method.DeclaringType.FullyQualifiedName);
            if (typeDef != null)
                typeDef.Methods.Add(emittedMehtod);

            Manager.ResourceManager.CurrentModule.RemoveFromLoadedTypes(targtMet.DeclaringType.FullName);

            dIL.AddRange(log.codeIL);
            if (SymbolWriter != null) {
                List<SequencePoint> points = SymbolWriter.EmitMethod(log.destToken, log.srcToken);
                NewMethodsSequencePoints.Add(targtMet.MetadataToken.ToUInt32(), points);
            }
        }
开发者ID:maresja1,项目名称:SDenc,代码行数:32,代码来源:DeltaBuilder.cs


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