public void Serialize(ref MessagePackWriter writer, IReadOnlyReactiveProperty <T> value, MessagePackSerializerOptions options) { var rxProp = value as ReactiveProperty <T>; if (rxProp != null) { ReactivePropertyResolver.Instance.GetFormatterWithVerify <ReactiveProperty <T> >().Serialize(ref writer, rxProp, options); return; } var slimProp = value as ReactivePropertySlim <T>; if (slimProp != null) { ReactivePropertyResolver.Instance.GetFormatterWithVerify <ReactivePropertySlim <T> >().Serialize(ref writer, slimProp, options); return; } if (value == null) { writer.WriteNil(); } else { throw new InvalidOperationException("Serializer only supports ReactiveProperty<T> or ReactivePropertySlim<T>. If serialize is ReadOnlyReactiveProperty, should mark [Ignore] and restore on IMessagePackSerializationCallbackReceiver.OnAfterDeserialize. Type:" + value.GetType().Name); } }
public int Serialize(ref byte[] bytes, int offset, IReadOnlyReactiveProperty <T> value, IFormatterResolver formatterResolver) { var rxProp = value as ReactiveProperty <T>; if (rxProp != null) { return(ReactivePropertyResolver.Instance.GetFormatterWithVerify <ReactiveProperty <T> >().Serialize(ref bytes, offset, rxProp, formatterResolver)); } if (value == null) { return(MessagePackBinary.WriteNil(ref bytes, offset)); } else { throw new InvalidOperationException("Serializer only supports ReactiveProperty<T>. If serialize is ReadOnlyReactiveProperty, should mark [Ignore] and restore on IMessagePackSerializationCallbackReceiver.OnAfterDeserialize. Type:" + value.GetType().Name); } }