本文整理汇总了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());
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例8: PrepareMethod
[System.Security.SecurityCritical] // auto-generated_required
public static void PrepareMethod(RuntimeMethodHandle method)
{
unsafe
{
_PrepareMethod(method.GetMethodInfo(), null, 0);
}
}
示例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);
}
}
示例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;
}