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


C# RuntimeMethodHandle.GetMethodInfo方法代码示例

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


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

示例1: GetMethodFromHandle

        public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType)
        {
            if (handle.IsNullHandle())
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));

            return RuntimeType.GetMethodBase(declaringType.GetRuntimeType(), handle.GetMethodInfo());
        }
开发者ID:nietras,项目名称:coreclr,代码行数:7,代码来源:MethodBase.cs

示例2: GetMethodFromHandle

        public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
        {
            if (handle.IsNullHandle())
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));

#if !FEATURE_CORECLR
            if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage))
            {
                FrameworkEventSource.Log.BeginGetMethodFromHandle();
            }
#endif

            MethodBase m = RuntimeType.GetMethodBase(handle.GetMethodInfo());

            Type declaringType = m.DeclaringType;

#if !FEATURE_CORECLR
            if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage)  && declaringType != null)
            {
                FrameworkEventSource.Log.EndGetMethodFromHandle(declaringType.GetFullNameForEtw(), m.GetFullNameForEtw());
            }
#endif

            if (declaringType != null && declaringType.IsGenericType)
                throw new ArgumentException(String.Format(
                    CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGeneric"), 
                    m, declaringType.GetGenericTypeDefinition()));
 
            return m;
        }
开发者ID:peterdocter,项目名称:referencesource,代码行数:30,代码来源:methodbase.cs

示例3: GetTokenFor

 public int GetTokenFor(RuntimeMethodHandle method)
 {
     IRuntimeMethodInfo methodInfo = method.GetMethodInfo();
     RuntimeMethodHandleInternal internal2 = methodInfo.Value;
     if ((methodInfo != null) && !RuntimeMethodHandle.IsDynamicMethod(internal2))
     {
         RuntimeType declaringType = RuntimeMethodHandle.GetDeclaringType(internal2);
         if ((declaringType != null) && RuntimeTypeHandle.IsGenericType(declaringType))
         {
             MethodBase methodBase = RuntimeType.GetMethodBase(methodInfo);
             Type genericTypeDefinition = methodBase.DeclaringType.GetGenericTypeDefinition();
             throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGenericLcg"), new object[] { methodBase, genericTypeDefinition }));
         }
     }
     this.m_tokens.Add(method);
     return ((this.m_tokens.Count - 1) | 0x6000000);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:DynamicScope.cs

示例4: GetMethodFromHandle

        public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
        {
            if (handle.IsNullHandle())
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));

#if MONO
            MethodBase m = GetMethodFromHandleInternalType (handle.Value, IntPtr.Zero);
            if (m == null)
                throw new ArgumentException ("The handle is invalid.");
#else
            MethodBase m = RuntimeType.GetMethodBase(handle.GetMethodInfo());
#endif

            Type declaringType = m.DeclaringType;
            if (declaringType != null && declaringType.IsGenericType)
                throw new ArgumentException(String.Format(
                    CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGeneric"), 
                    m, declaringType.GetGenericTypeDefinition()));
 
            return m;
        }
开发者ID:stormleoxia,项目名称:referencesource,代码行数:21,代码来源:methodbase.cs

示例5: CreateDelegateNoSecurityCheck

        [System.Security.SecurityCritical]  // auto-generated
        internal unsafe static Delegate CreateDelegateNoSecurityCheck(Type type, Object target, RuntimeMethodHandle method)
        {
            // Validate the parameters.
            if (type == null)
                throw new ArgumentNullException("type");
            Contract.EndContractBlock();

            if (method.IsNullHandle())
                throw new ArgumentNullException("method");

            RuntimeType rtType = type as RuntimeType;
            if (rtType == null)
                throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
            
            if (!rtType.IsDelegate())
                throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"),"type");
            
            // Initialize the method...
            Delegate d = InternalAlloc(rtType);
            // This is a new internal API added in Whidbey. Currently it's only
            // used by the dynamic method code to generate a wrapper delegate.
            // Allow flexible binding options since the target method is
            // unambiguously provided to us.
            // <

            if (!d.BindToMethodInfo(target,
                                    method.GetMethodInfo(),
                                    RuntimeMethodHandle.GetDeclaringType(method.GetMethodInfo()),
                                    DelegateBindingFlags.RelaxedSignature | DelegateBindingFlags.SkipSecurityChecks))
                throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
            return d;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:33,代码来源:Delegate.cs

示例6: GetTokenFor

        [System.Security.SecuritySafeCritical]  // auto-generated
        public int GetTokenFor(RuntimeMethodHandle method)
        {
            IRuntimeMethodInfo methodReal = method.GetMethodInfo();
            RuntimeMethodHandleInternal rmhi = methodReal.Value;

            if (methodReal != null && !RuntimeMethodHandle.IsDynamicMethod(rmhi))
            {
                RuntimeType type = RuntimeMethodHandle.GetDeclaringType(rmhi);
                if ((type != null) && RuntimeTypeHandle.HasInstantiation(type))
                {
                    // Do we really need to retrieve this much info just to throw an exception?
                    MethodBase m = RuntimeType.GetMethodBase(methodReal);
                    Type t = m.DeclaringType.GetGenericTypeDefinition();

                    throw new ArgumentException(String.Format(
                        CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGenericLcg"), m, t));
                }
            }

            m_tokens.Add(method);
            return m_tokens.Count - 1 | (int)MetadataTokenType.MethodDef;
        }
开发者ID:Clockwork-Muse,项目名称:coreclr,代码行数:23,代码来源:DynamicILGenerator.cs

示例7: CreateDelegate

		internal static Delegate CreateDelegate(Type type, object target, RuntimeMethodHandle method)
		{
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			if (method.IsNullHandle())
			{
				throw new ArgumentNullException("method");
			}
			if (!(type is RuntimeType))
			{
				throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "type");
			}
			Type baseType = type.BaseType;
			if (baseType == null || baseType != typeof(MulticastDelegate))
			{
				throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), "type");
			}
			Delegate @delegate = Delegate.InternalAlloc(type.TypeHandle.GetRuntimeType());
			if ([email protected](target, method.GetMethodInfo(), RuntimeMethodHandle.GetDeclaringType(method.GetMethodInfo()), DelegateBindingFlags.RelaxedSignature))
			{
				throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth"));
			}
			return @delegate;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:26,代码来源:Delegate.cs

示例8: PrepareMethod

 [System.Security.SecurityCritical]  // auto-generated_required
 public static void PrepareMethod(RuntimeMethodHandle method) 
 {
     unsafe
     {
         _PrepareMethod(method.GetMethodInfo(), null, 0);
     }
 }
开发者ID:uQr,项目名称:referencesource,代码行数:8,代码来源:runtimehelpers.cs

示例9: PrepareMethod

 public static unsafe void PrepareMethod(RuntimeMethodHandle method, RuntimeTypeHandle[] instantiation)
 {
     int num;
     fixed (IntPtr* ptrRef = RuntimeTypeHandle.CopyRuntimeTypeHandles(instantiation, out num))
     {
         _PrepareMethod(method.GetMethodInfo(), ptrRef, num);
         GC.KeepAlive(instantiation);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:RuntimeHelpers.cs

示例10: GetMethodFromHandle

 public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle)
 {
     if (handle.IsNullHandle())
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));
     }
     MethodBase methodBase = RuntimeType.GetMethodBase(handle.GetMethodInfo());
     Type declaringType = methodBase.DeclaringType;
     if ((declaringType != null) && declaringType.IsGenericType)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGeneric"), new object[] { methodBase, declaringType.GetGenericTypeDefinition() }));
     }
     return methodBase;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:MethodBase.cs


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