Akka.Serialization.NewtonSoftJsonSerializer.FromBinary C# (CSharp) Method

FromBinary() public method

Deserializes a byte array into an object of type type.
public FromBinary ( byte bytes, Type type ) : object
bytes byte The array containing the serialized object
type System.Type The type of object contained in the array
return object
        public override object FromBinary(byte[] bytes, Type type)
        {
            string data = Encoding.UTF8.GetString(bytes);
            object res = JsonConvert.DeserializeObject(data, _settings);
            return TranslateSurrogate(res, this, type);
        }

Usage Example

 public void StateShouldBeSerializedAndDeserializedCorrectly(object sut)
 {
     var serializer = new NewtonSoftJsonSerializer(null);
     var bytes = serializer.ToBinary(sut);
     //var json = Encoding.Default.GetString(bytes);
     var result = (DeviceStoreState) serializer.FromBinary(bytes, typeof (DeviceStoreState));
     result.ShouldBeEquivalentTo(sut);
 }
All Usage Examples Of Akka.Serialization.NewtonSoftJsonSerializer::FromBinary