Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
        internal InnerErrorModel(InnerErrorCode code, string message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            Code    = code;
            Message = message;
            Details = new ChangeTrackingDictionary <string, string>();
        }
Ejemplo n.º 3
0
        internal static InnerErrorModel DeserializeInnerErrorModel(JsonElement element)
        {
            InnerErrorCode code    = default;
            string         message = default;
            Optional <IReadOnlyDictionary <string, string> > details = default;
            Optional <string>          target     = default;
            Optional <InnerErrorModel> innererror = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("code"))
                {
                    code = new InnerErrorCode(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("message"))
                {
                    message = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("details"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    details = dictionary;
                    continue;
                }
                if (property.NameEquals("target"))
                {
                    target = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("innererror"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    innererror = DeserializeInnerErrorModel(property.Value);
                    continue;
                }
            }
            return(new InnerErrorModel(code, message, Optional.ToDictionary(details), target.Value, innererror.Value));
        }