コード例 #1
0
 internal ErrorDetail(string code, string message, string target, IReadOnlyList <ErrorDetail> details, InnerError innererror)
 {
     Code       = code;
     Message    = message;
     Target     = target;
     Details    = details;
     Innererror = innererror;
 }
コード例 #2
0
        internal static ErrorDetail DeserializeErrorDetail(JsonElement element)
        {
            string            code    = default;
            string            message = default;
            Optional <string> target  = default;
            Optional <IReadOnlyList <ErrorDetail> > details = default;
            Optional <InnerError> innererror = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("code"))
                {
                    code = 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 <ErrorDetail> array = new List <ErrorDetail>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DeserializeErrorDetail(item));
                    }
                    details = array;
                    continue;
                }
                if (property.NameEquals("innererror"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    innererror = InnerError.DeserializeInnerError(property.Value);
                    continue;
                }
            }
            return(new ErrorDetail(code, message, target.Value, Optional.ToList(details), innererror.Value));
        }