public override object DeserializeObject(object value, Type type)
 {
     if (type == typeof(DynamicResponse))
     {
         var dict = base.DeserializeObject(value, typeof(IDictionary <string, object>)) as IDictionary <string, object>;
         return(dict == null ? null : DynamicResponse.Create(dict));
     }
     if (type == typeof(ServerError))
     {
         var dict = base.DeserializeObject(value, typeof(IDictionary <string, object>)) as IDictionary <string, object>;
         return(ServerError.Create(dict, this));
     }
     if (type == typeof(Error))
     {
         var dict = base.DeserializeObject(value, typeof(IDictionary <string, object>)) as IDictionary <string, object>;
         return(Error.Create(dict, this));
     }
     if (type == typeof(RootCause))
     {
         var dict = base.DeserializeObject(value, typeof(IDictionary <string, object>)) as IDictionary <string, object>;
         return(RootCause.Create(dict, this));
     }
     if (type == typeof(CausedBy))
     {
         var dict = base.DeserializeObject(value, typeof(IDictionary <string, object>)) as IDictionary <string, object>;
         return(CausedBy.Create(dict, this));
     }
     return(base.DeserializeObject(value, type));
 }
Exemplo n.º 2
0
        public override object DeserializeObject(object value, Type type)
        {
            if (type == typeof(DynamicBody))
            {
                var dict = base.DeserializeObject(value, typeof(IDictionary <string, object>)) as IDictionary <string, object>;
                return(dict == null ? null : DynamicBody.Create(dict));
            }
            if (type == typeof(ServerError))
            {
                var dict = base.DeserializeObject(value, typeof(IDictionary <string, object>)) as IDictionary <string, object>;
                return(ServerError.Create(dict, this));
            }
            if (type == typeof(ShardFailure))
            {
                var dict = base.DeserializeObject(value, typeof(IDictionary <string, object>)) as IDictionary <string, object>;
                return(ShardFailure.CreateShardFailure(dict, this));
            }
            if (type == typeof(Error))
            {
                if (value is string s)
                {
                    return new Error {
                               Reason = s
                    }
                }
                ;

                var dict = base.DeserializeObject(value, typeof(IDictionary <string, object>)) as IDictionary <string, object>;
                return(Error.CreateError(dict, this));
            }
            if (type == typeof(ErrorCause))
            {
                if (value is string s)
                {
                    return new ErrorCause {
                               Reason = s
                    }
                }
                ;

                var dict = base.DeserializeObject(value, typeof(IDictionary <string, object>)) as IDictionary <string, object>;
                return(ErrorCause.CreateErrorCause(dict, this));
            }
            return(base.DeserializeObject(value, type));
        }
    }
}