private void ReadExtType(byte extType, ArraySegment <byte> data, int pos) { switch ((MsgPackExtType)extType) { case MsgPackExtType.DateTimeOld: this.Value.SetValue(new DateTime(bitConverter.ToInt64(data.Array, data.Offset), DateTimeKind.Utc), JsonToken.DateTime, pos); break; case MsgPackExtType.DateTime: this.Value.SetValue(new DateTime(bitConverter.ToInt64(data.Array, data.Offset + 1), (DateTimeKind)data.Array[data.Offset]), JsonToken.DateTime, pos); break; case MsgPackExtType.DateTimeOffset: var time = new DateTime(bitConverter.ToInt64(data.Array, data.Offset), DateTimeKind.Utc); var offset = new TimeSpan(bitConverter.ToInt64(data.Array, data.Offset + 8)); this.Value.SetValue(new DateTimeOffset(time, offset), JsonToken.DateTime, pos); break; case MsgPackExtType.DecimalOld: case MsgPackExtType.Decimal: this.Value.SetValue(bitConverter.ToDecimal(data.Array, data.Offset), JsonToken.Number, pos); break; default: throw new UnknownMsgPackExtentionTypeException(extType); } }
private void ReadExtType(byte extType, ArraySegment <byte> data, int pos) { switch ((MsgPackExtType)extType) { case MsgPackExtType.DateTime: this.Value.SetValue(new DateTime(bitConverter.ToInt64(data.Array, data.Offset), DateTimeKind.Utc), JsonToken.DateTime, pos); break; case MsgPackExtType.Decimal: this.Value.SetValue(bitConverter.ToDecimal(data.Array, data.Offset), JsonToken.Number, pos); break; case MsgPackExtType.JsonString: this.Value.SetValue(new JsonString(this.Context.Encoding.GetString(data.Array, data.Offset, data.Count)), JsonToken.StringLiteral, pos); break; default: throw new UnknownMsgPackExtentionTypeException(extType); } }