public static RemotableNotification <T> ReadFrom(Stream stream, IRedisValueConverter converter) { using (var br = new BinaryReader(stream, Encoding.UTF8, leaveOpen: false)) { var value = new RemotableNotification <T>(); value.Kind = (NotificationKind)br.ReadInt32(); switch (value.Kind) { case NotificationKind.OnCompleted: break; case NotificationKind.OnError: value.ErrorMessage = br.ReadString(); break; case NotificationKind.OnNext: using (var restMemory = new MemoryStream()) { stream.CopyTo(restMemory); value.Value = converter.Deserialize <T>(restMemory.ToArray()); } break; default: throw new InvalidOperationException("Invalid Kind"); } return(value); } }
public static T Deserialize <T>(this IRedisValueConverter converter, byte[] value) { return((T)converter.Deserialize(typeof(T), value)); }
public static T Deserialize <T>(this IRedisValueConverter converter, RedisValue value, out long valueSize) { return((T)converter.Deserialize(typeof(T), value, out valueSize)); }