本文整理汇总了C#中CorElementType类的典型用法代码示例。如果您正苦于以下问题:C# CorElementType类的具体用法?C# CorElementType怎么用?C# CorElementType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CorElementType类属于命名空间,在下文中一共展示了CorElementType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValid
public static bool IsValid(CorElementType elementType)
{
return (CorElementType.End <= elementType && elementType <= CorElementType.Max) ||
elementType == CorElementType.Modifier ||
elementType == CorElementType.Sentinel ||
elementType == CorElementType.Pinned;
}
示例2: MiniParameterInfo
public MiniParameterInfo(CorElementType elementType)
{
System.Diagnostics.Contracts.Contract.Requires(elementType <= CorElementType.String ||
elementType == CorElementType.I || elementType == CorElementType.U ||
elementType == CorElementType.Object);
_elementType = elementType;
}
示例3: DebuggerType
public DebuggerType(Debugger debugger, CorType type, uint token = 0)
{
debugger.Dispatcher.VerifyAccess();
this.debugger = debugger;
this.type = type;
this.hashCode = type.GetHashCode();
this.elementType = (CorElementType)type.ElementType;
this.attributes = type.GetTypeAttributes();
this.token = token;
this.tokenInitd = token != 0;
}
示例4: CorFieldInfo
public CorFieldInfo(CorType ownerType, uint token, string name, TypeSig fieldType, FieldAttributes attrs, object constant, CorElementType constantType, DebuggerBrowsableState? debuggerBrowsableState, bool compilerGeneratedAttribute) {
this.OwnerType = ownerType;
this.Token = token;
this.Name = name;
this.FieldType = fieldType;
this.Attributes = attrs;
this.Constant = constant;
this.ConstantType = constantType;
this.DebuggerBrowsableState = debuggerBrowsableState;
this.CompilerGeneratedAttribute = compilerGeneratedAttribute;
}
示例5: GetParameterizedType
public CorType GetParameterizedType(CorElementType elementType, CorType[] typeArguments)
{
ICorDebugType[] types = null;
uint length = 0;
if (typeArguments != null)
{
types = new ICorDebugType[typeArguments.Length];
for (int i = 0; i < typeArguments.Length; i++)
types[i] = typeArguments[i].m_type;
length = (uint)typeArguments.Length;
}
ICorDebugType pType;
(m_class as ICorDebugClass2).GetParameterizedType(elementType, length, types, out pType);
return pType==null?null:new CorType (pType);
}
示例6: GetPrimitiveType
IDebuggerType GetPrimitiveType(CorElementType etype) {
switch (etype) {
case CorElementType.Void: return appDomain.Void;
case CorElementType.Boolean: return appDomain.Boolean;
case CorElementType.Char: return appDomain.Char;
case CorElementType.I1: return appDomain.SByte;
case CorElementType.U1: return appDomain.Byte;
case CorElementType.I2: return appDomain.Int16;
case CorElementType.U2: return appDomain.UInt16;
case CorElementType.I4: return appDomain.Int32;
case CorElementType.U4: return appDomain.UInt32;
case CorElementType.I8: return appDomain.Int64;
case CorElementType.U8: return appDomain.UInt64;
case CorElementType.R4: return appDomain.Single;
case CorElementType.R8: return appDomain.Double;
case CorElementType.String: return appDomain.String;
case CorElementType.TypedByRef: return appDomain.TypedReference;
case CorElementType.I: return appDomain.IntPtr;
case CorElementType.U: return appDomain.UIntPtr;
case CorElementType.Object: return appDomain.Object;
default: return null;
}
}
示例7: ParseIntegerConstant
static ulong? ParseIntegerConstant(CorElementType etype, string c, out string error) {
error = null;
long smin, smax;
ulong max;
switch (etype) {
case CorElementType.Boolean:
smin = 0;
smax = 1;
max = 1;
break;
case CorElementType.I:
if (IntPtr.Size == 4)
goto case CorElementType.I4;
goto case CorElementType.I8;
case CorElementType.U:
case CorElementType.Ptr:
case CorElementType.FnPtr:
if (UIntPtr.Size == 4)
goto case CorElementType.U4;
goto case CorElementType.U8;
case CorElementType.I1:
case CorElementType.U1:
smin = sbyte.MinValue;
smax = sbyte.MaxValue;
max = byte.MaxValue;
break;
case CorElementType.I2:
case CorElementType.U2:
smin = short.MinValue;
smax = short.MaxValue;
max = ushort.MaxValue;
break;
case CorElementType.I4:
case CorElementType.U4:
smin = int.MinValue;
smax = int.MaxValue;
max = uint.MaxValue;
break;
case CorElementType.I8:
case CorElementType.U8:
smin = long.MinValue;
smax = long.MaxValue;
max = ulong.MaxValue;
break;
default:
return null;
}
ulong v = NumberVMUtils.ParseUInt64(c, 0, max, out error);
if (string.IsNullOrEmpty(error))
return v;
v = (ulong)NumberVMUtils.ParseInt64(c, smin, smax, out error);
if (string.IsNullOrEmpty(error))
return v;
return null;
}
示例8: Convert
static byte[] Convert(CorElementType etype, object c) {
var tc = c == null ? TypeCode.Empty : Type.GetTypeCode(c.GetType());
switch (tc) {
case TypeCode.Boolean:
if (etype == CorElementType.Boolean)
return new byte[1] { (byte)((bool)c ? 1 : 0) };
return null;
case TypeCode.Char:
if (etype == CorElementType.Char)
return BitConverter.GetBytes((char)c);
return null;
case TypeCode.SByte:
if (etype == CorElementType.I1)
return new byte[1] { (byte)(sbyte)c };
return null;
case TypeCode.Int16:
if (etype == CorElementType.I2)
return BitConverter.GetBytes((short)c);
return null;
case TypeCode.Int32:
if (etype == CorElementType.I4)
return BitConverter.GetBytes((int)c);
return null;
case TypeCode.Int64:
if (etype == CorElementType.I8)
return BitConverter.GetBytes((long)c);
return null;
case TypeCode.Byte:
if (etype == CorElementType.U1)
return new byte[1] { (byte)c };
return null;
case TypeCode.UInt16:
if (etype == CorElementType.U2)
return BitConverter.GetBytes((ushort)c);
return null;
case TypeCode.UInt32:
if (etype == CorElementType.U4)
return BitConverter.GetBytes((uint)c);
return null;
case TypeCode.UInt64:
if (etype == CorElementType.U8)
return BitConverter.GetBytes((ulong)c);
return null;
case TypeCode.Single:
if (etype == CorElementType.R4)
return BitConverter.GetBytes((float)c);
return null;
case TypeCode.Double:
if (etype == CorElementType.R8)
return BitConverter.GetBytes((double)c);
return null;
}
return null;
}
示例9: GetDefaultValue
public void GetDefaultValue(int mdToken, out long value, out int length, out CorElementType corElementType)
{
int num;
_GetDefaultValue(this.m_metadataImport2, out MetadataArgs.Skip, mdToken, out value, out length, out num);
corElementType = (CorElementType) ((byte) num);
}
示例10: ConvertUInt64
static object ConvertUInt64(CorElementType etype, ulong v) {
switch (etype) {
case CorElementType.Boolean:
return v != 0;
case CorElementType.I:
if (IntPtr.Size == 4)
goto case CorElementType.I4;
goto case CorElementType.I8;
case CorElementType.I1: return (sbyte)v;
case CorElementType.I2: return (short)v;
case CorElementType.I4: return (int)v;
case CorElementType.I8: return (long)v;
case CorElementType.U:
if (UIntPtr.Size == 4)
goto case CorElementType.U4;
goto case CorElementType.U8;
case CorElementType.U1: return (byte)v;
case CorElementType.U2: return (ushort)v;
case CorElementType.U4: return (uint)v;
case CorElementType.U8: return v;
}
return null;
}
示例11: GetFieldConstant
public unsafe static object GetFieldConstant(IMetaDataImport mdi, uint token, out CorElementType constantType) {
constantType = CorElementType.End;
if (mdi == null)
return null;
uint cchValue;
IntPtr pValue;
CorElementType constantTypeTmp;
int hr = mdi.GetFieldProps(token, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, new IntPtr(&constantTypeTmp), new IntPtr(&pValue), new IntPtr(&cchValue));
if (hr < 0 || pValue == IntPtr.Zero)
return null;
constantType = constantTypeTmp;
return ReadConstant(pValue, cchValue, constantType);
}
示例12: AddElementType
private void AddElementType(CorElementType cvt)
{
if ((this.m_currSig + 1) > this.m_signature.Length)
{
this.m_signature = this.ExpandArray(this.m_signature);
}
this.m_signature[this.m_currSig++] = (byte) cvt;
}
示例13: AddElementType
private void AddElementType(CorElementType cvt)
{
// Adds an element to the signature. A managed represenation of CorSigCompressElement
if (m_currSig + 1 > m_signature.Length)
m_signature = ExpandArray(m_signature);
m_signature[m_currSig++] = (byte)cvt;
}
示例14: UnsafeGetValueAsType
public Object UnsafeGetValueAsType(CorElementType type)
{
switch(type)
{
case CorElementType.ELEMENT_TYPE_BOOLEAN:
byte bValue=4; // just initialize to avoid compiler warnings
unsafe
{
Debug.Assert(this.Size==sizeof(byte));
this.GetValueInternal(new IntPtr(&bValue));
}
return (object) (bValue!=0);
case CorElementType.ELEMENT_TYPE_CHAR:
char cValue='a'; // initialize to avoid compiler warnings
unsafe
{
Debug.Assert(this.Size==sizeof(char));
this.GetValueInternal(new IntPtr(&cValue));
}
return (object) cValue;
case CorElementType.ELEMENT_TYPE_I1:
SByte i1Value=4;
unsafe
{
Debug.Assert(this.Size==sizeof(SByte));
this.GetValueInternal(new IntPtr(&i1Value));
}
return (object) i1Value;
case CorElementType.ELEMENT_TYPE_U1:
Byte u1Value=4;
unsafe
{
Debug.Assert(this.Size==sizeof(Byte));
this.GetValueInternal(new IntPtr(&u1Value));
}
return (object) u1Value;
case CorElementType.ELEMENT_TYPE_I2:
Int16 i2Value=4;
unsafe
{
Debug.Assert(this.Size==sizeof(Int16));
this.GetValueInternal(new IntPtr(&i2Value));
}
return (object) i2Value;
case CorElementType.ELEMENT_TYPE_U2:
UInt16 u2Value=4;
unsafe
{
Debug.Assert(this.Size==sizeof(UInt16));
this.GetValueInternal(new IntPtr(&u2Value));
}
return (object) u2Value;
case CorElementType.ELEMENT_TYPE_I:
IntPtr ipValue=IntPtr.Zero;
unsafe
{
Debug.Assert(this.Size==sizeof(IntPtr));
this.GetValueInternal(new IntPtr(&ipValue));
}
return (object) ipValue;
case CorElementType.ELEMENT_TYPE_U:
UIntPtr uipValue=UIntPtr.Zero;
unsafe
{
Debug.Assert(this.Size==sizeof(UIntPtr));
this.GetValueInternal(new IntPtr(&uipValue));
}
return (object) uipValue;
case CorElementType.ELEMENT_TYPE_I4:
Int32 i4Value=4;
unsafe
{
Debug.Assert(this.Size==sizeof(Int32));
this.GetValueInternal(new IntPtr(&i4Value));
}
return (object) i4Value;
case CorElementType.ELEMENT_TYPE_U4:
UInt32 u4Value=4;
unsafe
{
Debug.Assert(this.Size==sizeof(UInt32));
this.GetValueInternal(new IntPtr(&u4Value));
}
return (object) u4Value;
case CorElementType.ELEMENT_TYPE_I8:
Int64 i8Value=4;
unsafe
{
Debug.Assert(this.Size==sizeof(Int64));
this.GetValueInternal(new IntPtr(&i8Value));
//.........这里部分代码省略.........
示例15: GetDefaultValue
[System.Security.SecurityCritical] // auto-generated
public String GetDefaultValue(int mdToken, out long value, out int length, out CorElementType corElementType)
{
int _corElementType;
String stringVal;
stringVal = _GetDefaultValue(m_metadataImport2, mdToken, out value, out length, out _corElementType);
corElementType = (CorElementType)_corElementType;
return stringVal;
}