protected internal override DateTimeOffset UnpackFromCore(Unpacker unpacker) { 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.AsInt64())); } }
public static Int16 UnpackInt16Value(Unpacker unpacker, Type objectType, String memberName) { try { Int16 result; if (!unpacker.ReadInt16(out result)) { throw SerializationExceptions.NewFailedToDeserializeMember(objectType, memberName, null); } return(result); } catch (MessageTypeException ex) { throw SerializationExceptions.NewFailedToDeserializeMember(objectType, memberName, ex); } }
public static Int16 UnpackInt16Value( Unpacker unpacker, Type objectType, String memberName ) { try { Int16 result; if ( !unpacker.ReadInt16( out result ) ) { throw SerializationExceptions.NewFailedToDeserializeMember( objectType, memberName, null ); } return result; } catch ( MessageTypeException ex ) { throw SerializationExceptions.NewFailedToDeserializeMember( objectType, memberName, ex ); } }
public static Int16 UnpackInt16Value( Unpacker unpacker, Type objectType, String memberName ) { if ( unpacker == null ) { SerializationExceptions.ThrowArgumentNullException( "unpacker" ); } if ( objectType == null ) { SerializationExceptions.ThrowArgumentNullException( "objectType" ); } if ( memberName == null ) { SerializationExceptions.ThrowArgumentNullException( "memberName" ); } #if ASSERT Contract.Assert( unpacker != null ); Contract.Assert( objectType != null ); Contract.Assert( memberName != null ); #endif // ASSERT // ReSharper disable once RedundantAssignment var ctx = default( UnpackerTraceContext ); InitializeUnpackerTrace( unpacker, ref ctx ); try { Int16 result; if ( !unpacker.ReadInt16( out result ) ) { SerializationExceptions.ThrowFailedToDeserializeMember( objectType, memberName, null ); } Trace( ctx, "ReadDirect", unpacker, memberName ); return result; } catch ( MessageTypeException ex ) { SerializationExceptions.ThrowFailedToDeserializeMember( objectType, memberName, ex ); return default( Int16 ); // never reaches. } }