IKVM.Reflection.Type.GetEnumUnderlyingTypeImpl C# (CSharp) Method

GetEnumUnderlyingTypeImpl() private method

private GetEnumUnderlyingTypeImpl ( ) : Type
return Type
        internal Type GetEnumUnderlyingTypeImpl()
        {
            foreach (FieldInfo field in __GetDeclaredFields())
            {
                if (!field.IsStatic)
                {
                    // the CLR assumes that an enum has only one instance field, so we can do the same
                    return field.FieldType;
                }
            }
            throw new InvalidOperationException();
        }

Usage Example

		private static CustomAttributeTypedArgument ReadFixedArg(Module context, ByteReader br, Type type)
		{
			Universe u = context.universe;
			if (type == u.System_String)
			{
				return new CustomAttributeTypedArgument(type, br.ReadString());
			}
			else if (type == u.System_Boolean)
			{
				return new CustomAttributeTypedArgument(type, br.ReadByte() != 0);
			}
			else if (type == u.System_Char)
			{
				return new CustomAttributeTypedArgument(type, br.ReadChar());
			}
			else if (type == u.System_Single)
			{
				return new CustomAttributeTypedArgument(type, br.ReadSingle());
			}
			else if (type == u.System_Double)
			{
				return new CustomAttributeTypedArgument(type, br.ReadDouble());
			}
			else if (type == u.System_SByte)
			{
				return new CustomAttributeTypedArgument(type, br.ReadSByte());
			}
			else if (type == u.System_Int16)
			{
				return new CustomAttributeTypedArgument(type, br.ReadInt16());
			}
			else if (type == u.System_Int32)
			{
				return new CustomAttributeTypedArgument(type, br.ReadInt32());
			}
			else if (type == u.System_Int64)
			{
				return new CustomAttributeTypedArgument(type, br.ReadInt64());
			}
			else if (type == u.System_Byte)
			{
				return new CustomAttributeTypedArgument(type, br.ReadByte());
			}
			else if (type == u.System_UInt16)
			{
				return new CustomAttributeTypedArgument(type, br.ReadUInt16());
			}
			else if (type == u.System_UInt32)
			{
				return new CustomAttributeTypedArgument(type, br.ReadUInt32());
			}
			else if (type == u.System_UInt64)
			{
				return new CustomAttributeTypedArgument(type, br.ReadUInt64());
			}
			else if (type == u.System_Type)
			{
				return new CustomAttributeTypedArgument(type, ReadType(context, br));
			}
			else if (type == u.System_Object)
			{
				return ReadFixedArg(context, br, ReadFieldOrPropType(context, br));
			}
			else if (type.IsArray)
			{
				int length = br.ReadInt32();
				if (length == -1)
				{
					return new CustomAttributeTypedArgument(type, null);
				}
				Type elementType = type.GetElementType();
				CustomAttributeTypedArgument[] array = new CustomAttributeTypedArgument[length];
				for (int i = 0; i < length; i++)
				{
					array[i] = ReadFixedArg(context, br, elementType);
				}
				return new CustomAttributeTypedArgument(type, array);
			}
			else if (type.IsEnum)
			{
				return new CustomAttributeTypedArgument(type, ReadFixedArg(context, br, type.GetEnumUnderlyingTypeImpl()).Value);
			}
			else
			{
				throw new InvalidOperationException();
			}
		}
All Usage Examples Of IKVM.Reflection.Type::GetEnumUnderlyingTypeImpl