Beispiel #1
0
        private static object TranslateSurrogate(object deserializedValue, CrossPlatformNewtonSoftJsonSerializer 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);
        }
Beispiel #2
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="parent">TBD</param>
 public SurrogateConverter(CrossPlatformNewtonSoftJsonSerializer parent)
 {
     _parent = parent;
 }