private static object TranslateSurrogate(object deserializedValue,NewtonSoftJsonSerializer parent,Type type)
{
var j = deserializedValue as JObject;
if (j != null)
{
//The JObject represents a special akka.net wrapper for primitives (int,float,decimal) to preserve correct type when deserializing
if (j["$"] != null)
{
var value = j["$"].Value<string>();
return GetValue(value);
}
//The JObject is not of our concern, let Json.NET deserialize it.
return j.ToObject(type, parent._serializer);
}
var surrogate = deserializedValue as ISurrogate;
//The deserialized object is a surrogate, unwrap it
if (surrogate != null)
{
return surrogate.FromSurrogate(parent.system);
}
return deserializedValue;
}