Exemple #1
0
 public static object Deserialize(this JToken data, ReferenceCollection references, object existingValue = default)
 {
     if (data.Type == JTokenType.Null)
     {
         return(null);
     }
     if (data.Type == JTokenType.Integer)
     {
         if (references.TryGetReferenceByID(data.Value <long>(), out var r))
         {
             if (r.Object is object obj)
             {
                 return(obj);
             }
             else
             {
                 r.Deserialize(references, existingValue);
                 return(r.Object);
             }
         }
         else
         {
             throw new ArgumentOutOfRangeException();
         }
     }
     else if (data.Type == JTokenType.String)
     {
         string[] s = Regex.Split(data.Value <string>(), @"^\[(.+)PublicKeyToken=(\w+)\]\[(.+)\]$");
         return(FromType(TypeEditionHelper.FromString($"{s[1]}PublicKeyToken={s[2]}")).DeserializeCore(s[3], references, existingValue));
     }
     else
     {
         throw new ArgumentOutOfRangeException();
     }
 }