本文整理匯總了C#中System.RuntimeTypeHandle.MakeGenericType方法的典型用法代碼示例。如果您正苦於以下問題:C# RuntimeTypeHandle.MakeGenericType方法的具體用法?C# RuntimeTypeHandle.MakeGenericType怎麽用?C# RuntimeTypeHandle.MakeGenericType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.RuntimeTypeHandle
的用法示例。
在下文中一共展示了RuntimeTypeHandle.MakeGenericType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetTypeHelper
internal static unsafe IntPtr GetTypeHelper(IntPtr th, IntPtr pGenericArgs, int cGenericArgs, IntPtr pModifiers, int cModifiers)
{
Type runtimeType = new RuntimeTypeHandle(th.ToPointer()).GetRuntimeType();
if (runtimeType == null)
{
return th;
}
if (cGenericArgs > 0)
{
Type[] typeArguments = new Type[cGenericArgs];
void** voidPtr = (void**) pGenericArgs.ToPointer();
for (int i = 0; i < typeArguments.Length; i++)
{
RuntimeTypeHandle handle = new RuntimeTypeHandle((void*) Marshal.ReadIntPtr((IntPtr) voidPtr, i * sizeof(void*)));
typeArguments[i] = Type.GetTypeFromHandle(handle);
if (typeArguments[i] == null)
{
return IntPtr.Zero;
}
}
runtimeType = runtimeType.MakeGenericType(typeArguments);
}
if (cModifiers > 0)
{
int* numPtr = (int*) pModifiers.ToPointer();
for (int j = 0; j < cModifiers; j++)
{
if (((byte) Marshal.ReadInt32((IntPtr) numPtr, j * 4)) == 15)
{
runtimeType = runtimeType.MakePointerType();
}
else if (((byte) Marshal.ReadInt32((IntPtr) numPtr, j * 4)) == 0x10)
{
runtimeType = runtimeType.MakeByRefType();
}
else if (((byte) Marshal.ReadInt32((IntPtr) numPtr, j * 4)) == 0x1d)
{
runtimeType = runtimeType.MakeArrayType();
}
else
{
runtimeType = runtimeType.MakeArrayType(Marshal.ReadInt32((IntPtr) numPtr, ++j * 4));
}
}
}
return runtimeType.GetTypeHandleInternal().Value;
}