示例#1
0
 internal Error(ErrorCode code, string message, string target, IReadOnlyList <Error> details, InnerErrorModel innererror)
 {
     Code       = code;
     Message    = message;
     Target     = target;
     Details    = details;
     Innererror = innererror;
 }
示例#2
0
 internal InnerErrorModel(InnerErrorCode code, string message, IReadOnlyDictionary <string, string> details, string target, InnerErrorModel innererror)
 {
     Code       = code;
     Message    = message;
     Details    = details;
     Target     = target;
     Innererror = innererror;
 }
示例#3
0
        internal static Error DeserializeError(JsonElement element)
        {
            ErrorCode         code    = default;
            string            message = default;
            Optional <string> target  = default;
            Optional <IReadOnlyList <Error> > details    = default;
            Optional <InnerErrorModel>        innererror = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("code"))
                {
                    code = new ErrorCode(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("message"))
                {
                    message = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("target"))
                {
                    target = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("details"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Error> array = new List <Error>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DeserializeError(item));
                    }
                    details = array;
                    continue;
                }
                if (property.NameEquals("innererror"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    innererror = InnerErrorModel.DeserializeInnerErrorModel(property.Value);
                    continue;
                }
            }
            return(new Error(code, message, target.Value, Optional.ToList(details), innererror.Value));
        }