本文整理汇总了C#中System.RuntimeMethodHandle类的典型用法代码示例。如果您正苦于以下问题:C# RuntimeMethodHandle类的具体用法?C# RuntimeMethodHandle怎么用?C# RuntimeMethodHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeMethodHandle类属于System命名空间,在下文中一共展示了RuntimeMethodHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenMethodResolver
public unsafe OpenMethodResolver(RuntimeTypeHandle declaringTypeOfSlot, RuntimeMethodHandle gvmSlot, int handle)
{
_resolveType = GVMResolve;
_methodHandleOrSlotOrCodePointer = *(IntPtr*)&gvmSlot;
_declaringType = declaringTypeOfSlot;
_handle = handle;
}
示例2: DeclareRoutine
/// <summary>
/// Adds referenced symbol into the map.
/// In case of redeclaration, the handle is added to the list.
/// </summary>
public static void DeclareRoutine(string name, RuntimeMethodHandle handle)
{
// TODO: W lock
int index;
if (NameToIndex.TryGetValue(name, out index))
{
Debug.Assert(index != 0);
if (index > 0) // already taken by user routine
{
throw new InvalidOperationException();
}
((ClrRoutineInfo)AppRoutines[-index - 1]).AddOverload(handle);
}
else
{
index = -AppRoutines.Count - 1;
var routine = new ClrRoutineInfo(index, name, handle);
AppRoutines.Add(routine);
NameToIndex[name] = index;
// register the routine within the extensions table
ExtensionsAppContext.ExtensionsTable.AddRoutine(routine);
}
}
示例3: RedirectCalls
public static RedirectCallsState RedirectCalls(RuntimeMethodHandle from, RuntimeMethodHandle to)
{
// GetFunctionPointer enforces compilation of the method.
var fptr1 = from.GetFunctionPointer();
var fptr2 = to.GetFunctionPointer();
return PatchJumpTo(fptr1, fptr2);
}
示例4: ArgumentInfo
public ArgumentInfo(RuntimeMethodHandle getMethod, string name, bool optional, object defaultValue)
{
this.getMethod = getMethod;
this.name = name;
this.optional = optional;
this.defaultValue = defaultValue;
}
示例5: 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;
}
示例6: 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());
}
示例7: GenerateDelegate
private static FastInvoker GenerateDelegate(RuntimeMethodHandle methodHandle)
{
var methodInfo = (MethodInfo)MethodBase.GetMethodFromHandle(methodHandle);
var dynamicMethod = new DynamicMethod(string.Empty, typeof(object), new[] { typeof(object), typeof(object[]) }, methodInfo.DeclaringType.Module);
var il = dynamicMethod.GetILGenerator();
var ps = methodInfo.GetParameters();
var paramTypes = new Type[ps.Length];
for (var i = 0; i < paramTypes.Length; i++)
{
if (ps[i].ParameterType.IsByRef)
{
paramTypes[i] = ps[i].ParameterType.GetElementType();
}
else
{
paramTypes[i] = ps[i].ParameterType;
}
}
var locals = new LocalBuilder[paramTypes.Length];
for (var i = 0; i < paramTypes.Length; i++)
{
locals[i] = il.DeclareLocal(paramTypes[i], true);
}
for (var i = 0; i < paramTypes.Length; i++)
{
il.Emit(OpCodes.Ldarg_1);
il.EmitFastInt(i);
il.Emit(OpCodes.Ldelem_Ref);
il.EmitCastToReference(paramTypes[i]);
il.Emit(OpCodes.Stloc, locals[i]);
}
if (!methodInfo.IsStatic)
{
il.Emit(OpCodes.Ldarg_0);
}
for (var i = 0; i < paramTypes.Length; i++)
{
il.Emit(ps[i].ParameterType.IsByRef ? OpCodes.Ldloca_S : OpCodes.Ldloc, locals[i]);
}
il.EmitCall(methodInfo.IsStatic ? OpCodes.Call : OpCodes.Callvirt, methodInfo, null);
if (methodInfo.ReturnType == typeof(void))
{
il.Emit(OpCodes.Ldnull);
}
else
{
il.BoxIfNeeded(methodInfo.ReturnType);
}
il.Emit(OpCodes.Ret);
var invoker = (FastInvoker)dynamicMethod.CreateDelegate(typeof(FastInvoker));
return invoker;
}
示例8: CheckSetDemand
internal bool CheckSetDemand(PermissionSet pset, RuntimeMethodHandle rmh)
{
this.CompleteConstruction(null);
if (this.PLS == null)
{
return false;
}
return this.PLS.CheckSetDemand(pset, rmh);
}
示例9: CheckDemand
internal bool CheckDemand(CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandle rmh)
{
this.CompleteConstruction(null);
if (this.PLS != null)
{
this.PLS.CheckDemand(demand, permToken, rmh);
}
return false;
}
示例10: ProxyInvocation
public ProxyInvocation(Delegate callback, Func<Delegate, object[], object> callbackCaller,
RuntimeMethodHandle methodHandle, RuntimeTypeHandle typeHandle, object proxy, object[] arguments)
{
this.callback = callback;
this.callbackCaller = callbackCaller;
this.methodHandle = methodHandle;
this.typeHandle = typeHandle;
this.proxy = proxy;
this.arguments = arguments;
}
示例11: RuntimeConstructorInfo
internal RuntimeConstructorInfo(RuntimeMethodHandle handle, RuntimeTypeHandle declaringTypeHandle, RuntimeType.RuntimeTypeCache reflectedTypeCache, MethodAttributes methodAttributes, System.Reflection.BindingFlags bindingFlags)
{
this.m_bindingFlags = bindingFlags;
this.m_handle = handle;
this.m_reflectedTypeCache = reflectedTypeCache;
this.m_declaringType = declaringTypeHandle.GetRuntimeType();
this.m_parameters = null;
this.m_toString = null;
this.m_methodAttributes = methodAttributes;
}
示例12: CreateCaObject
private static unsafe object CreateCaObject(Module module, RuntimeMethodHandle ctor, ref IntPtr blob, IntPtr blobEnd, out int namedArgs)
{
int num;
byte* ppBlob = (byte*) blob;
byte* pEndBlob = (byte*) blobEnd;
object obj2 = _CreateCaObject(module.ModuleHandle.Value, (void*) ctor.Value, &ppBlob, pEndBlob, &num);
blob = (IntPtr) ppBlob;
namedArgs = num;
return obj2;
}
示例13: SetUp
public void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
// we do this in SetUp because we want the security
// stack to be "normal/empty" so each unit test can
// mess with it as it wishes
handle = typeof (RuntimeMethodHandleCas).GetMethod ("SetUp").MethodHandle;
}
示例14: GetGraphTypesFromMethodHandle
/// <summary>
/// Returns the graph types for a method specified by a method handle.
/// </summary>
/// <param name="handle">The handle to the method.</param>
/// <returns>The graph types for the method.</returns>
public static Type[] GetGraphTypesFromMethodHandle(RuntimeMethodHandle handle)
{
return _types.GetOrAdd(
handle,
h =>
{
MethodInfo method = (MethodInfo)MethodInfo.GetMethodFromHandle(h);
var graphAttribute = method.GetCustomAttributes(false).OfType<DefaultGraphAttribute>().FirstOrDefault();
return graphAttribute.GraphTypes;
});
}
示例15: MethodInvoker
protected MethodInvoker( RuntimeMethodHandle targetMethod, Func<object> instanceFactory )
{
if ( instanceFactory == null )
{
throw new ArgumentNullException( "instanceFactory" );
}
Contract.EndContractBlock();
this._targetMethod = targetMethod;
this._instanceFactory = instanceFactory;
}