本文整理汇总了C#中ModuleBuilder.GetTypeToken方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleBuilder.GetTypeToken方法的具体用法?C# ModuleBuilder.GetTypeToken怎么用?C# ModuleBuilder.GetTypeToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleBuilder
的用法示例。
在下文中一共展示了ModuleBuilder.GetTypeToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteGenericSignature
private static void WriteGenericSignature(ModuleBuilder module, ByteBuffer bb, Type type)
{
Type[] typeArguments = type.GetGenericArguments();
CustomModifiers[] customModifiers = type.__GetGenericArgumentsCustomModifiers();
if (!type.IsGenericTypeDefinition)
{
type = type.GetGenericTypeDefinition();
}
bb.Write(ELEMENT_TYPE_GENERICINST);
if (type.IsValueType)
{
bb.Write(ELEMENT_TYPE_VALUETYPE);
}
else
{
bb.Write(ELEMENT_TYPE_CLASS);
}
bb.WriteTypeDefOrRefEncoded(module.GetTypeToken(type).Token);
bb.WriteCompressedUInt(typeArguments.Length);
for (int i = 0; i < typeArguments.Length; i++)
{
WriteCustomModifiers(module, bb, customModifiers[i]);
WriteType(module, bb, typeArguments[i]);
}
}
示例2: WriteType
//.........这里部分代码省略.........
{
bb.Write(ELEMENT_TYPE_VOID);
}
else if (type == u.System_Int32)
{
bb.Write(ELEMENT_TYPE_I4);
}
else if (type == u.System_Boolean)
{
bb.Write(ELEMENT_TYPE_BOOLEAN);
}
else if (type == u.System_String)
{
bb.Write(ELEMENT_TYPE_STRING);
}
else if (type == u.System_Char)
{
bb.Write(ELEMENT_TYPE_CHAR);
}
else if (type == u.System_SByte)
{
bb.Write(ELEMENT_TYPE_I1);
}
else if (type == u.System_Byte)
{
bb.Write(ELEMENT_TYPE_U1);
}
else if (type == u.System_Int16)
{
bb.Write(ELEMENT_TYPE_I2);
}
else if (type == u.System_UInt16)
{
bb.Write(ELEMENT_TYPE_U2);
}
else if (type == u.System_UInt32)
{
bb.Write(ELEMENT_TYPE_U4);
}
else if (type == u.System_Int64)
{
bb.Write(ELEMENT_TYPE_I8);
}
else if (type == u.System_UInt64)
{
bb.Write(ELEMENT_TYPE_U8);
}
else if (type == u.System_Single)
{
bb.Write(ELEMENT_TYPE_R4);
}
else if (type == u.System_Double)
{
bb.Write(ELEMENT_TYPE_R8);
}
else if (type == u.System_IntPtr)
{
bb.Write(ELEMENT_TYPE_I);
}
else if (type == u.System_UIntPtr)
{
bb.Write(ELEMENT_TYPE_U);
}
else if (type == u.System_TypedReference)
{
bb.Write(ELEMENT_TYPE_TYPEDBYREF);
}
else if (type == u.System_Object)
{
bb.Write(ELEMENT_TYPE_OBJECT);
}
else if (type.IsGenericParameter)
{
if (type is UnboundGenericMethodParameter || type.DeclaringMethod != null)
{
bb.Write(ELEMENT_TYPE_MVAR);
}
else
{
bb.Write(ELEMENT_TYPE_VAR);
}
bb.WriteCompressedInt(type.GenericParameterPosition);
}
else if (type.IsGenericType)
{
WriteGenericSignature(module, bb, type);
}
else
{
if (type.IsValueType)
{
bb.Write(ELEMENT_TYPE_VALUETYPE);
}
else
{
bb.Write(ELEMENT_TYPE_CLASS);
}
bb.WriteTypeDefOrRefEncoded(module.GetTypeToken(type).Token);
}
}
示例3: WriteType
protected static void WriteType(ModuleBuilder module, ByteBuffer bb, Type type)
{
while (type.HasElementType)
{
byte sigElementType = type.SigElementType;
bb.Write(sigElementType);
if (sigElementType == ELEMENT_TYPE_ARRAY)
{
// LAMESPEC the Type production (23.2.12) doesn't include CustomMod* for arrays, but the verifier allows it and ildasm also supports it
WriteCustomModifiers(module, bb, type.__GetCustomModifiers());
WriteType(module, bb, type.GetElementType());
bb.WriteCompressedUInt(type.GetArrayRank());
int[] sizes = type.__GetArraySizes();
bb.WriteCompressedUInt(sizes.Length);
for (int i = 0; i < sizes.Length; i++)
{
bb.WriteCompressedUInt(sizes[i]);
}
int[] lobounds = type.__GetArrayLowerBounds();
bb.WriteCompressedUInt(lobounds.Length);
for (int i = 0; i < lobounds.Length; i++)
{
bb.WriteCompressedInt(lobounds[i]);
}
return;
}
WriteCustomModifiers(module, bb, type.__GetCustomModifiers());
type = type.GetElementType();
}
if (type.__IsBuiltIn)
{
bb.Write(type.SigElementType);
}
else if (type.IsGenericParameter)
{
bb.Write(type.SigElementType);
bb.WriteCompressedUInt(type.GenericParameterPosition);
}
else if (!type.__IsMissing && type.IsGenericType)
{
WriteGenericSignature(module, bb, type);
}
else if (type.__IsFunctionPointer)
{
bb.Write(ELEMENT_TYPE_FNPTR);
WriteStandAloneMethodSig(module, bb, type.__MethodSignature);
}
else
{
if (type.IsValueType)
{
bb.Write(ELEMENT_TYPE_VALUETYPE);
}
else
{
bb.Write(ELEMENT_TYPE_CLASS);
}
bb.WriteTypeDefOrRefEncoded(module.GetTypeToken(type).Token);
}
}
示例4: WriteType
//.........这里部分代码省略.........
bb.Write(ELEMENT_TYPE_I4);
}
else if (type == u.System_Boolean)
{
bb.Write(ELEMENT_TYPE_BOOLEAN);
}
else if (type == u.System_String)
{
bb.Write(ELEMENT_TYPE_STRING);
}
else if (type == u.System_Char)
{
bb.Write(ELEMENT_TYPE_CHAR);
}
else if (type == u.System_SByte)
{
bb.Write(ELEMENT_TYPE_I1);
}
else if (type == u.System_Byte)
{
bb.Write(ELEMENT_TYPE_U1);
}
else if (type == u.System_Int16)
{
bb.Write(ELEMENT_TYPE_I2);
}
else if (type == u.System_UInt16)
{
bb.Write(ELEMENT_TYPE_U2);
}
else if (type == u.System_UInt32)
{
bb.Write(ELEMENT_TYPE_U4);
}
else if (type == u.System_Int64)
{
bb.Write(ELEMENT_TYPE_I8);
}
else if (type == u.System_UInt64)
{
bb.Write(ELEMENT_TYPE_U8);
}
else if (type == u.System_Single)
{
bb.Write(ELEMENT_TYPE_R4);
}
else if (type == u.System_Double)
{
bb.Write(ELEMENT_TYPE_R8);
}
else if (type == u.System_IntPtr)
{
bb.Write(ELEMENT_TYPE_I);
}
else if (type == u.System_UIntPtr)
{
bb.Write(ELEMENT_TYPE_U);
}
else if (type == u.System_TypedReference)
{
bb.Write(ELEMENT_TYPE_TYPEDBYREF);
}
else if (type == u.System_Object)
{
bb.Write(ELEMENT_TYPE_OBJECT);
}
else if (type.IsGenericParameter)
{
if (type is UnboundGenericMethodParameter || type.DeclaringMethod != null)
{
bb.Write(ELEMENT_TYPE_MVAR);
}
else
{
bb.Write(ELEMENT_TYPE_VAR);
}
bb.WriteCompressedInt(type.GenericParameterPosition);
}
else if (!type.__IsMissing && type.IsGenericType)
{
WriteGenericSignature(module, bb, type);
}
else if (type.__IsFunctionPointer)
{
bb.Write(ELEMENT_TYPE_FNPTR);
WriteStandAloneMethodSig(module, bb, type.__MethodSignature);
}
else
{
if (type.IsValueType)
{
bb.Write(ELEMENT_TYPE_VALUETYPE);
}
else
{
bb.Write(ELEMENT_TYPE_CLASS);
}
bb.WriteTypeDefOrRefEncoded(module.GetTypeToken(type).Token);
}
}