protected internal static Object ReadPrimitiveValue(IParsingContext context, PrimitiveTypeEnumeration type) { switch (type) { case PrimitiveTypeEnumeration.Boolean: return context.ReadBoolean(); case PrimitiveTypeEnumeration.Byte: return context.ReadByte(); case PrimitiveTypeEnumeration.Char: return context.ReadChar(); case PrimitiveTypeEnumeration.DateTime: var data = context.ReadInt64(); var dt = DateTime.FromBinary(data); var dtUtc = dt.ToUniversalTime(); return new DateTime(dtUtc.Ticks, dt.Kind); case PrimitiveTypeEnumeration.Decimal: return Decimal.Parse(context.ReadString(), CultureInfo.InvariantCulture); case PrimitiveTypeEnumeration.Double: return context.ReadDouble(); case PrimitiveTypeEnumeration.Int16: return context.ReadInt16(); case PrimitiveTypeEnumeration.Int32: return context.ReadInt32(); case PrimitiveTypeEnumeration.Int64: return context.ReadInt64(); case PrimitiveTypeEnumeration.Null: return null; case PrimitiveTypeEnumeration.SByte: return context.ReadSByte(); case PrimitiveTypeEnumeration.Single: return context.ReadSingle(); case PrimitiveTypeEnumeration.String: return context.ReadString(); case PrimitiveTypeEnumeration.TimeSpan: return TimeSpan.FromTicks(context.ReadInt64()); case PrimitiveTypeEnumeration.UInt16: return context.ReadUInt16(); case PrimitiveTypeEnumeration.UInt32: return context.ReadUInt32(); case PrimitiveTypeEnumeration.UInt64: return context.ReadUInt64(); default: throw new NotSupportedException("Unsupported primitive type " + type); } }