当前位置: 首页>>代码示例>>C#>>正文


C# Type.GetEnumUnderlyingType方法代码示例

本文整理汇总了C#中System.Type.GetEnumUnderlyingType方法的典型用法代码示例。如果您正苦于以下问题:C# Type.GetEnumUnderlyingType方法的具体用法?C# Type.GetEnumUnderlyingType怎么用?C# Type.GetEnumUnderlyingType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Type的用法示例。


在下文中一共展示了Type.GetEnumUnderlyingType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateEnumTypeDeclaration

	private void GenerateEnumTypeDeclaration(Type enumType)
	{
		DataContractAttribute dataContractAttr = (DataContractAttribute)Attribute.GetCustomAttribute(enumType, typeof(DataContractAttribute));
        if (dataContractAttr != null)
        {
			this.GenerateDataContractAttribute(enumType);
		}
		
		if (enumType.GetCustomAttributes(typeof(FlagsAttribute), false).Length > 0)
        {

this.Write("[System.Flags]\r\n");


		}
		
		
this.Write("public enum ");

this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenUtilities.GetSafeName(enumType.Name)));


		
		Type underlyingType = enumType.GetEnumUnderlyingType();
        if (underlyingType != typeof(int))
		{
			
this.Write(" : ");

this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenUtilities.GetTypeName(underlyingType)));


		}
	}
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:34,代码来源:CSharpEnumGenerator.cs

示例2: EnumConfiguration

 public EnumConfiguration(Type enumType)
 {
     _signed = IsSignedEnum(enumType);
     _flags = IsFlagsEnum(enumType);
     _names = enumType.GetEnumNames();
     var members = enumType.GetMembers(BindingFlags.Static | BindingFlags.Public);
     Debug.Assert(members.Length == _names.Length);
     for (int i = 0; i < members.Length; i++)
     {
         var a = members[i].GetCustomAttributes<PersistedNameAttribute>().FirstOrDefault();
         if (a != null) _names[i] = a.Name;
     }
     var undertype = enumType.GetEnumUnderlyingType();
     var enumValues = enumType.GetEnumValues();
     IEnumerable<ulong> enumValuesUlongs;
     if (undertype == typeof(int)) enumValuesUlongs = enumValues.Cast<int>().Select(i => (ulong)i);
     else if (undertype == typeof(uint)) enumValuesUlongs = enumValues.Cast<uint>().Select(i => (ulong)i);
     else if (undertype == typeof(sbyte)) enumValuesUlongs = enumValues.Cast<sbyte>().Select(i => (ulong)i);
     else if (undertype == typeof(byte)) enumValuesUlongs = enumValues.Cast<byte>().Select(i => (ulong)i);
     else if (undertype == typeof(short)) enumValuesUlongs = enumValues.Cast<short>().Select(i => (ulong)i);
     else if (undertype == typeof(ushort)) enumValuesUlongs = enumValues.Cast<ushort>().Select(i => (ulong)i);
     else if (undertype == typeof(long)) enumValuesUlongs = enumValues.Cast<long>().Select(i => (ulong)i);
     else enumValuesUlongs = enumValues.Cast<ulong>();
     _values = enumValuesUlongs.ToArray();
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:25,代码来源:EnumFieldHandler.cs

示例3: ToQuotedString

        public override string ToQuotedString(Type fieldType, object value)
        {
            if (fieldType.HasAttribute<EnumAsIntAttribute>())
            {
                return this.ConvertNumber(fieldType.GetEnumUnderlyingType(), value).ToString();
            }

            if (value is int && !fieldType.IsEnumFlags())
            {
                value = fieldType.GetEnumName(value);
            }

            if (fieldType.IsEnum)
            {
                var enumValue = DialectProvider.StringSerializer.SerializeToString(value);
                // Oracle stores empty strings in varchar columns as null so match that behavior here
                if (enumValue == null)
                    return null;
                enumValue = DialectProvider.GetQuotedValue(enumValue.Trim('"'));
                return enumValue == "''"
                    ? "null"
                    : enumValue;
            }
            return base.ToQuotedString(fieldType, value);
        }
开发者ID:ServiceStack,项目名称:ServiceStack.OrmLite,代码行数:25,代码来源:OracleEnumConverter.cs

示例4: GenerateEnum2EnumConversion

 Action<IILGen> GenerateEnum2EnumConversion(Type from, Type to)
 {
     var fromcfg = new EnumFieldHandler.EnumConfiguration(from);
     var tocfg = new EnumFieldHandler.EnumConfiguration(to);
     if (fromcfg.IsSubsetOf(tocfg))
     {
         return GenerateConversion(from.GetEnumUnderlyingType(), to.GetEnumUnderlyingType());
     }
     return null;
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:10,代码来源:DefaultTypeConvertorGenerator.cs

示例5: TypeToAutomationType

 public static UIAutomationType TypeToAutomationType(Type type)
 {
     if (IsElementOnServerSide(type))
         return UIAutomationType.UIAutomationType_Element;
     if (type.IsEnum && type.GetEnumUnderlyingType() == typeof(int))
         type = typeof(int);
     UIAutomationType res;
     if (_typeMapping.TryGetValue(type, out res))
         return res;
     throw new NotSupportedException("Provided type is not supported");
 }
开发者ID:TestStack,项目名称:uia-custom-pattern-managed,代码行数:11,代码来源:UiaTypesHelper.cs

示例6: GetConvertedValue

        protected Expression GetConvertedValue(Type targetType)
        {
            var value = ExtendedProperties.GetExtendedProperty("value") ?? String.Empty;

            if (targetType.IsEnum)
                return Expression.Constant(((IConvertible)Enum.Parse(targetType, value, true)).ToType(targetType.GetEnumUnderlyingType(), CultureInfo.InvariantCulture));

            return typeof(IConvertible).IsAssignableFrom(targetType)
                        ? Expression.Constant(((IConvertible)value).ToType(targetType, CultureInfo.InvariantCulture))
                        : Expression.Convert(Expression.Constant(value), targetType) as Expression;
        }
开发者ID:jeoffman,项目名称:Harvester,代码行数:11,代码来源:ComparisonFilterBase.cs

示例7: WriteEnumList

        /// <summary>
        /// </summary>
        /// <param name="fileName">
        /// </param>
        /// <param name="enumName">
        /// </param>
        /// <param name="enumType">
        /// </param>
        /// <param name="writeValues">
        /// </param>
        public static void WriteEnumList(string fileName, string enumName, Type enumType, bool writeValues = true)
        {
            bool isFlagsEnum = false;
            object[] memInfo = enumType.GetCustomAttributes(typeof(FlagsAttribute), false);
            isFlagsEnum = memInfo.Length > 0;

            TextWriter tw = new StreamWriter(fileName);

            WriteHeader1(tw, enumName);
            WriteCode(tw, enumType.FullName);
            if (writeValues)
            {
                tw.Write(" : ");
                WriteCode(tw, enumType.GetEnumUnderlyingType().Name);
            }

            if (isFlagsEnum)
            {
                tw.WriteLine();
                tw.WriteLine();
                WriteCode(tw, "[Flags]");
            }

            tw.WriteLine();
            WriteHorizonalLine(tw);
            tw.WriteLine();
            Array temp2 = Enum.GetValues(enumType);

            int max = temp2.Length;
            foreach (object v in temp2)
            {
                string eName = Enum.GetName(enumType, v);
                tw.Write("**" + eName + "**");
                if (writeValues)
                {
                    object underlyingValue = Convert.ChangeType(v, Enum.GetUnderlyingType(v.GetType()));
                    tw.Write(" = " + underlyingValue);
                }

                max--;
                if (max > 0)
                {
                    tw.WriteLine(",");
                }

                tw.WriteLine();
            }

            WriteFooter(tw);
            tw.Close();
        }
开发者ID:gordonc64,项目名称:CellAO.Tools,代码行数:61,代码来源:Program.cs

示例8: ReadEnum

        public Enum ReadEnum(Type enumType, ByteOrder byteOrder)
        {
            Require.NotNull(enumType, "enumType");
            Require.That("enumType", enumType.IsEnum);

            var enumBaseType = enumType.GetEnumUnderlyingType();
            if (enumBaseType == typeof(byte))
            {
                var value = ReadByte();
                return (Enum)Enum.ToObject(enumType, value);
            }
            if (enumBaseType == typeof(sbyte))
            {
                var value = ReadSByte();
                return (Enum)Enum.ToObject(enumType, value);
            }
            if(enumBaseType == typeof(int))
            {
                var value = ReadInt32(byteOrder);
                return (Enum)Enum.ToObject(enumType, value);
            }
            if (enumBaseType == typeof(uint))
            {
                var value = ReadUInt32(byteOrder);
                return (Enum)Enum.ToObject(enumType, value);
            }
            if (enumBaseType == typeof(short))
            {
                var value = ReadInt16(byteOrder);
                return (Enum)Enum.ToObject(enumType, value);
            }
            if (enumBaseType == typeof(ushort))
            {
                var value = ReadUInt16(byteOrder);
                return (Enum)Enum.ToObject(enumType, value);
            }
            if (enumBaseType == typeof(long))
            {
                var value = ReadInt64(byteOrder);
                return (Enum)Enum.ToObject(enumType, value);
            }
            if (enumBaseType == typeof(ulong))
            {
                var value = ReadUInt64(byteOrder);
                return (Enum)Enum.ToObject(enumType, value);
            }
            throw new ArgumentOutOfRangeException("enumType", "The provided argument did not meet the specified requirements.");
        }
开发者ID:mattchamb,项目名称:Construct.NET,代码行数:48,代码来源:ConstructReaderStream.cs

示例9: EmitLdDefaultValue

        public static void EmitLdDefaultValue(this ILGenerator gen, Type returnType)
        {
            if (returnType.IsEnum)
                returnType = returnType.GetEnumUnderlyingType();

            if (returnType==typeof(void)) {}
            else if (returnType.IsClass || returnType.IsInterface)
            {
                gen.Emit(OpCodes.Ldnull);
            }
            else if (I4CompatibleTypes.Contains(returnType))
            {
                gen.Emit(OpCodes.Ldc_I4_0);
            }
            else if (returnType==typeof(double))
            {
                gen.Emit(OpCodes.Ldc_R8, 0.0);
            }
            else if (returnType==typeof(float))
            {
                gen.Emit(OpCodes.Ldc_R4, 0.0f);
            }
            else if (returnType==typeof(long) || returnType==typeof(ulong))
            {
                gen.Emit(OpCodes.Ldc_I8, 0L);
            }
            else if (returnType==typeof(decimal))
            {
                var consDecimal = typeof(decimal).GetConstructor(new[] {typeof(int)});
                gen.Emit(OpCodes.Ldc_I4_0);
                gen.Emit(OpCodes.Newobj, consDecimal);
            }
            else if (returnType.IsValueType)
            {
                var returnTypeLocal = gen.DeclareLocal(returnType);
                gen.Emit(OpCodes.Ldloca, returnTypeLocal);
                gen.Emit(OpCodes.Initobj, returnType);
                gen.Emit(OpCodes.Ldloc, returnTypeLocal);
            }
            else
            {
                throw new InvalidOperationException("Unable to handle return type");
            }
        }
开发者ID:davidvmckay,项目名称:ProxyFoo,代码行数:44,代码来源:ILGenerator+Extensions.cs

示例10: EnumTypeDescriptor

 public EnumTypeDescriptor(ITypeDescriptorCallbacks typeSerializers, Type type)
 {
     _typeSerializers = typeSerializers;
     _type = type;
     _name = typeSerializers.TypeNameMapper.ToName(type);
     _signed = IsSignedEnum(type);
     _flags = IsFlagsEnum(type);
     var undertype = type.GetEnumUnderlyingType();
     var enumValues = type.GetEnumValues();
     IEnumerable<ulong> enumValuesUlongs;
     if (undertype == typeof(int)) enumValuesUlongs = enumValues.Cast<int>().Select(i => (ulong)i);
     else if (undertype == typeof(uint)) enumValuesUlongs = enumValues.Cast<uint>().Select(i => (ulong)i);
     else if (undertype == typeof(sbyte)) enumValuesUlongs = enumValues.Cast<sbyte>().Select(i => (ulong)i);
     else if (undertype == typeof(byte)) enumValuesUlongs = enumValues.Cast<byte>().Select(i => (ulong)i);
     else if (undertype == typeof(short)) enumValuesUlongs = enumValues.Cast<short>().Select(i => (ulong)i);
     else if (undertype == typeof(ushort)) enumValuesUlongs = enumValues.Cast<ushort>().Select(i => (ulong)i);
     else if (undertype == typeof(long)) enumValuesUlongs = enumValues.Cast<long>().Select(i => (ulong)i);
     else enumValuesUlongs = enumValues.Cast<ulong>();
     _pairs = type.GetEnumNames().Zip(enumValuesUlongs.ToArray(), (s, v) => new KeyValuePair<string, ulong>(s, v)).ToList();
 }
开发者ID:klesta490,项目名称:BTDB,代码行数:20,代码来源:EnumTypeDescriptor.cs

示例11: ToQuotedString

        public override string ToQuotedString(Type fieldType, object value)
        {
            var isEnumAsInt = fieldType.HasAttribute<EnumAsIntAttribute>();
            if (isEnumAsInt)
                return this.ConvertNumber(fieldType.GetEnumUnderlyingType(), value).ToString();

            var isEnumFlags = fieldType.IsEnumFlags() ||
                (!fieldType.IsEnum && fieldType.IsNumericType()); //i.e. is real int && not Enum

            long enumValue;
            if (!isEnumFlags && long.TryParse(value.ToString(), out enumValue))
                value = Enum.ToObject(fieldType, enumValue);

            var enumString = DialectProvider.StringSerializer.SerializeToString(value);
            if (enumString == null || enumString == "null")
                enumString = value.ToString();

            return !isEnumFlags 
                ? DialectProvider.GetQuotedValue(enumString.Trim('"')) 
                : enumString;
        }
开发者ID:brian6peng,项目名称:ServiceStack.OrmLite,代码行数:21,代码来源:SpecialConverters.cs

示例12: WritePrimitiveValue

		/// <summary>
		/// Writes a primitive value of the specified type.
		/// Stack transition: ..., writer, value => ...
		/// </summary>
		void WritePrimitiveValue(ILGenerator il, Type fieldType)
		{
			if (fieldType.IsEnum) {
				fieldType = fieldType.GetEnumUnderlyingType();
				Debug.Assert(fieldType.IsPrimitive);
			}
			switch (Type.GetTypeCode(fieldType)) {
				case TypeCode.Boolean:
				case TypeCode.SByte:
				case TypeCode.Byte:
					il.Emit(callVirt, writeByte); // writer.Write(value);
					break;
				case TypeCode.Char:
				case TypeCode.Int16:
				case TypeCode.UInt16:
					il.Emit(callVirt, writeShort); // writer.Write(value);
					break;
				case TypeCode.Int32:
				case TypeCode.UInt32:
					il.Emit(callVirt, writeInt); // writer.Write(value);
					break;
				case TypeCode.Int64:
				case TypeCode.UInt64:
					il.Emit(callVirt, writeLong); // writer.Write(value);
					break;
				case TypeCode.Single:
					il.Emit(callVirt, writeFloat); // writer.Write(value);
					break;
				case TypeCode.Double:
					il.Emit(callVirt, writeDouble); // writer.Write(value);
					break;
				default:
					throw new NotSupportedException("Unknown primitive type " + fieldType);
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:39,代码来源:FastSerializer.cs

示例13: CreateWriter

		ObjectWriter CreateWriter(Type type)
		{
			if (type == typeof(string)) {
				// String contents are written in the object creation section,
				// not into the field value section.
				return delegate {};
			}
			bool isArray = type.IsArray;
			if (isArray) {
				if (type.GetArrayRank() != 1)
					throw new NotSupportedException();
				type = type.GetElementType();
				if (!type.IsValueType) {
					return delegate (SerializationContext context, object array) {
						foreach (object val in (object[])array) {
							context.WriteObjectID(val);
						}
					};
				} else if (type == typeof(byte)) {
					return delegate (SerializationContext context, object array) {
						context.writer.Write((byte[])array);
					};
				}
			}
			List<FieldInfo> fields = GetSerializableFields(type);
			if (fields.Count == 0) {
				// The writer has nothing to do for this object.
				return delegate { };
			}
			
			
			DynamicMethod dynamicMethod = new DynamicMethod(
				(isArray ? "WriteArray_" : "Write_") + type.Name,
				typeof(void), new [] { typeof(SerializationContext), typeof(object) },
				true);
			ILGenerator il = dynamicMethod.GetILGenerator();
			
			var writer = il.DeclareLocal(typeof(BinaryWriter));
			
			il.Emit(OpCodes.Ldarg_0);
			il.Emit(OpCodes.Ldfld, writerField);
			il.Emit(OpCodes.Stloc, writer); // writer = context.writer;
			
			if (isArray) {
				var instance = il.DeclareLocal(type.MakeArrayType());
				il.Emit(OpCodes.Ldarg_1);
				il.Emit(OpCodes.Castclass, type.MakeArrayType());
				il.Emit(OpCodes.Stloc, instance); // instance = (type[])arg_1;
				
				// for (int i = 0; i < instance.Length; i++) write instance[i];
				
				var loopStart = il.DefineLabel();
				var loopHead = il.DefineLabel();
				var loopVariable = il.DeclareLocal(typeof(int));
				il.Emit(OpCodes.Ldc_I4_0);
				il.Emit(OpCodes.Stloc, loopVariable); // loopVariable = 0
				il.Emit(OpCodes.Br, loopHead); // goto loopHead;
				
				il.MarkLabel(loopStart);
				
				if (type.IsEnum || type.IsPrimitive) {
					if (type.IsEnum) {
						type = type.GetEnumUnderlyingType();
					}
					Debug.Assert(type.IsPrimitive);
					il.Emit(OpCodes.Ldloc, writer); // writer
					il.Emit(OpCodes.Ldloc, instance); // writer, instance
					il.Emit(OpCodes.Ldloc, loopVariable); // writer, instance, loopVariable
					switch (Type.GetTypeCode(type)) {
						case TypeCode.Boolean:
						case TypeCode.SByte:
						case TypeCode.Byte:
							il.Emit(OpCodes.Ldelem_I1); // writer, instance[loopVariable]
							il.Emit(callVirt, writeByte); // writer.Write(instance[loopVariable]);
							break;
						case TypeCode.Char:
						case TypeCode.Int16:
						case TypeCode.UInt16:
							il.Emit(OpCodes.Ldelem_I2); // writer, instance[loopVariable]
							il.Emit(callVirt, writeShort); // writer.Write(instance[loopVariable]);
							break;
						case TypeCode.Int32:
						case TypeCode.UInt32:
							il.Emit(OpCodes.Ldelem_I4);  // writer, instance[loopVariable]
							il.Emit(callVirt, writeInt); // writer.Write(instance[loopVariable]);
							break;
						case TypeCode.Int64:
						case TypeCode.UInt64:
							il.Emit(OpCodes.Ldelem_I8);  // writer, instance[loopVariable]
							il.Emit(callVirt, writeLong); // writer.Write(instance[loopVariable]);
							break;
						case TypeCode.Single:
							il.Emit(OpCodes.Ldelem_R4);  // writer, instance[loopVariable]
							il.Emit(callVirt, writeFloat); // writer.Write(instance[loopVariable]);
							break;
						case TypeCode.Double:
							il.Emit(OpCodes.Ldelem_R8);  // writer, instance[loopVariable]
							il.Emit(callVirt, writeDouble); // writer.Write(instance[loopVariable]);
							break;
						default:
//.........这里部分代码省略.........
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:101,代码来源:FastSerializer.cs

示例14: ReadPrimitiveValue

		/// <summary>
		/// Reads a primitive value of the specified type.
		/// Stack transition: ... => ..., value
		/// </summary>
		void ReadPrimitiveValue(ILGenerator il, LocalBuilder reader, Type fieldType)
		{
			if (fieldType.IsEnum) {
				fieldType = fieldType.GetEnumUnderlyingType();
				Debug.Assert(fieldType.IsPrimitive);
			}
			il.Emit(OpCodes.Ldloc, reader);
			switch (Type.GetTypeCode(fieldType)) {
				case TypeCode.Boolean:
				case TypeCode.SByte:
				case TypeCode.Byte:
					il.Emit(callVirt, readByte);
					break;
				case TypeCode.Char:
				case TypeCode.Int16:
				case TypeCode.UInt16:
					il.Emit(callVirt, readShort);
					break;
				case TypeCode.Int32:
				case TypeCode.UInt32:
					il.Emit(callVirt, readInt);
					break;
				case TypeCode.Int64:
				case TypeCode.UInt64:
					il.Emit(callVirt, readLong);
					break;
				case TypeCode.Single:
					il.Emit(callVirt, readFloat);
					break;
				case TypeCode.Double:
					il.Emit(callVirt, readDouble);
					break;
				default:
					throw new NotSupportedException("Unknown primitive type " + fieldType);
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:40,代码来源:FastSerializer.cs

示例15: CreateReader

		ObjectReader CreateReader(Type type)
		{
			if (type == typeof(string)) {
				// String contents are written in the object creation section,
				// not into the field value section; so there's nothing to read here.
				return delegate {};
			}
			bool isArray = type.IsArray;
			if (isArray) {
				if (type.GetArrayRank() != 1)
					throw new NotSupportedException();
				type = type.GetElementType();
				if (!type.IsValueType) {
					return delegate (DeserializationContext context, object arrayInstance) {
						object[] array = (object[])arrayInstance;
						for (int i = 0; i < array.Length; i++) {
							array[i] = context.ReadObject();
						}
					};
				} else if (type == typeof(byte)) {
					return delegate (DeserializationContext context, object arrayInstance) {
						byte[] array = (byte[])arrayInstance;
						BinaryReader binaryReader = context.Reader;
						int pos = 0;
						int bytesRead;
						do {
							bytesRead = binaryReader.Read(array, pos, array.Length - pos);
							pos += bytesRead;
						} while (bytesRead > 0);
						if (pos != array.Length)
							throw new EndOfStreamException();
					};
				}
			}
			var fields = GetSerializableFields(type);
			if (fields.Count == 0) {
				// The reader has nothing to do for this object.
				return delegate { };
			}
			
			DynamicMethod dynamicMethod = new DynamicMethod(
				(isArray ? "ReadArray_" : "Read_") + type.Name,
				MethodAttributes.Public | MethodAttributes.Static,
				CallingConventions.Standard,
				typeof(void), new [] { typeof(DeserializationContext), typeof(object) },
				type,
				true);
			ILGenerator il = dynamicMethod.GetILGenerator();
			
			var reader = il.DeclareLocal(typeof(BinaryReader));
			
			il.Emit(OpCodes.Ldarg_0);
			il.Emit(OpCodes.Ldfld, readerField);
			il.Emit(OpCodes.Stloc, reader); // reader = context.reader;
			
			if (isArray) {
				var instance = il.DeclareLocal(type.MakeArrayType());
				il.Emit(OpCodes.Ldarg_1);
				il.Emit(OpCodes.Castclass, type.MakeArrayType());
				il.Emit(OpCodes.Stloc, instance); // instance = (type[])arg_1;
				
				// for (int i = 0; i < instance.Length; i++) read &instance[i];
				
				var loopStart = il.DefineLabel();
				var loopHead = il.DefineLabel();
				var loopVariable = il.DeclareLocal(typeof(int));
				il.Emit(OpCodes.Ldc_I4_0);
				il.Emit(OpCodes.Stloc, loopVariable); // loopVariable = 0
				il.Emit(OpCodes.Br, loopHead); // goto loopHead;
				
				il.MarkLabel(loopStart);
				
				if (type.IsEnum || type.IsPrimitive) {
					if (type.IsEnum) {
						type = type.GetEnumUnderlyingType();
					}
					Debug.Assert(type.IsPrimitive);
					il.Emit(OpCodes.Ldloc, instance); // instance
					il.Emit(OpCodes.Ldloc, loopVariable); // instance, loopVariable
					ReadPrimitiveValue(il, reader, type); // instance, loopVariable, value
					switch (Type.GetTypeCode(type)) {
						case TypeCode.Boolean:
						case TypeCode.SByte:
						case TypeCode.Byte:
							il.Emit(OpCodes.Stelem_I1); // instance[loopVariable] = value;
							break;
						case TypeCode.Char:
						case TypeCode.Int16:
						case TypeCode.UInt16:
							il.Emit(OpCodes.Stelem_I2); // instance[loopVariable] = value;
							break;
						case TypeCode.Int32:
						case TypeCode.UInt32:
							il.Emit(OpCodes.Stelem_I4); // instance[loopVariable] = value;
							break;
						case TypeCode.Int64:
						case TypeCode.UInt64:
							il.Emit(OpCodes.Stelem_I8); // instance[loopVariable] = value;
							break;
						case TypeCode.Single:
//.........这里部分代码省略.........
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:101,代码来源:FastSerializer.cs


注:本文中的System.Type.GetEnumUnderlyingType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。