本文整理汇总了C#中System.RuntimeTypeHandle.MakePointerType方法的典型用法代码示例。如果您正苦于以下问题:C# RuntimeTypeHandle.MakePointerType方法的具体用法?C# RuntimeTypeHandle.MakePointerType怎么用?C# RuntimeTypeHandle.MakePointerType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.RuntimeTypeHandle
的用法示例。
在下文中一共展示了RuntimeTypeHandle.MakePointerType方法的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;
}