예제 #1
0
        protected internal override DateTimeOffset UnpackFromCore(Unpacker unpacker)
        {
            if (unpacker.LastReadData.IsTypeOf <MessagePackExtendedTypeObject>().GetValueOrDefault())
            {
                return(Timestamp.Decode(unpacker.LastReadData.DeserializeAsMessagePackExtendedTypeObject()).ToDateTimeOffset());
            }
            else if (unpacker.IsArrayHeader)
            {
                if (UnpackHelpers.GetItemsCount(unpacker) != 2)
                {
                    SerializationExceptions.ThrowInvalidArrayItemsCount(unpacker, typeof(DateTimeOffset), 2);
                }

                long ticks;
                if (!unpacker.ReadInt64(out ticks))
                {
                    SerializationExceptions.ThrowUnexpectedEndOfStream(unpacker);
                }

                short offsetMinutes;
                if (!unpacker.ReadInt16(out offsetMinutes))
                {
                    SerializationExceptions.ThrowUnexpectedEndOfStream(unpacker);
                }

                return(new DateTimeOffset(DateTime.FromBinary(ticks), TimeSpan.FromMinutes(offsetMinutes)));
            }
            else
            {
                return(MessagePackConvert.ToDateTimeOffset(unpacker.LastReadData.DeserializeAsInt64()));
            }
        }
예제 #2
0
 protected internal override FILETIME UnpackFromCore(Unpacker unpacker)
 {
     return(Timestamp.Decode(unpacker.LastReadData.DeserializeAsMessagePackExtendedTypeObject()).ToDateTime().ToWin32FileTimeUtc());
 }