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


C# MethodInfo.GetMethodImplementationFlags方法代码示例

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


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

示例1: PrintMethod

 private static void PrintMethod(MethodInfo method)
 {
     Console.Write("{0} {1}(", method.ReturnType.FullName, method.Name);
     foreach (ParameterInfo p in method.GetParameters())
         Console.Write("{0}, ", p.ParameterType.FullName);
     Console.WriteLine(")");
     Console.WriteLine("Attribs: {0}", method.Attributes);
     Console.WriteLine("Calling: {0}", method.CallingConvention);
     Console.WriteLine("Impl:    {0}", method.GetMethodImplementationFlags());
 }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:10,代码来源:GenProxyTests.cs

示例2: GrabPInvokeImpl

        protected MethodInfo GrabPInvokeImpl(MethodInfo Original, TypeBuilder On)
        {
            if (On == null)
                On = GrabType(Original.DeclaringType) as TypeBuilder;

            DllImportAttribute Attr = FindCustomAttribute<DllImportAttribute>(Original);
            if (Attr == null)
                throw new InvalidOperationException("P/Invoke method without a DllImportAttribute");

            Type ReturnType = GrabType(Original.ReturnType);
            Type[] Parameters = ParameterTypes(Original);

            if (MethodsDone.ContainsKey(Original))
                return MethodsDone[Original];

            MethodBuilder PInvoke = On.DefinePInvokeMethod(Original.Name, Attr.Value, Original.Attributes, Original.CallingConvention,
                ReturnType, Parameters, Attr.CallingConvention, Attr.CharSet);

            PInvoke.SetImplementationFlags(Original.GetMethodImplementationFlags());

            MethodsDone.Add(Original, PInvoke);

            return PInvoke;
        }
开发者ID:Tyelpion,项目名称:IronAHK,代码行数:24,代码来源:GrabMethod.cs

示例3: AppendMethodInfo

        static private void AppendMethodInfo(MethodInfo method, StringBuilder sb)
        {
            sb.Append(".method");

            foreach (var attribute in method.GetCustomAttributesData())
            {
                sb.Append(" ");
                AppendCustomAttributeData(attribute, sb);
            }

            sb.Append(" ");
            AppendMethodAttributes(sb, method.Attributes);
            sb.Append(" ");
            AppendParameterInfo(method.ReturnParameter, sb);
            sb.Append(" ");
            sb.Append(method.Name);

            if (method.IsGenericMethod)
            {
                sb.Append("<");
                foreach (var typeParameter in method.GetGenericArguments())
                {
                    AppendType(typeParameter, sb, true);
                    AppendComma(sb);
                }
                RemoveTrailingComma(sb);
                sb.Append(">");
            }

            sb.Append("(");
            foreach (var parameter in method.GetParameters())
            {
                AppendParameterInfo(parameter, sb);
                AppendComma(sb);
            }
            RemoveTrailingComma(sb);
            sb.Append(") ");
            AppendMethodImplAttributes(sb, method.GetMethodImplementationFlags());
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:39,代码来源:MetadataSignatureHelper.cs

示例4: GrabMethod

        protected MethodInfo GrabMethod(MethodInfo Original, TypeBuilder On)
        {
            if (Original == null) return null;

            if (MethodsDone.ContainsKey(Original))
                return MethodsDone[Original];

            if (!Sources.Contains(Original.Module))
                return MethodReplaceGenerics(Original);

            if (On == null)
                On = GrabType(Original.DeclaringType) as TypeBuilder;

            if ((Original.Attributes & MethodAttributes.PinvokeImpl) == MethodAttributes.PinvokeImpl)
                return GrabPInvokeImpl(Original, On);

            Type ReturnType = GrabType(Original.ReturnType);
            Type[] Parameters = ParameterTypes(Original);

            if (MethodsDone.ContainsKey(Original))
                return MethodsDone[Original];

            MethodBuilder Builder = On.DefineMethod(Original.Name, Original.Attributes, ReturnType, Parameters);

            MethodsDone.Add(Original, Builder);

            // Explicit interface implementations require specifying which method is being overridden.
            if (Original.IsFinal)
            {
                if (Original.Name.Contains("."))
                {
                    MethodInfo Overriding = FindBaseMethod(Original, Original.DeclaringType);

                    if (Overriding != null)
                        On.DefineMethodOverride(Builder, Overriding);
                }
                else
                {
                    // Crawl among the interfaces attempting to guess the method that is being overridden.
                    foreach (Type T in Original.DeclaringType.GetInterfaces())
                    {
                        foreach (MethodInfo M in T.GetMethods())
                        {
                            if (M.IsAbstract && M.Name == Original.Name)
                            {
                                On.DefineMethodOverride(Builder, M);

                                goto foundoverride; // For lack of "break 2" statement.
                            }
                        }
                    }
                }
            }

            foundoverride:

            Builder.SetImplementationFlags(Original.GetMethodImplementationFlags());

            CopyMethodBody(Original, Builder);

            return Builder;
        }
开发者ID:Tyelpion,项目名称:IronAHK,代码行数:62,代码来源:GrabMethod.cs


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