コード例 #1
0
 internal DocumentTranslationError(DocumentTranslationErrorCode?code, string message, string target, DocumentTranslationInnerError innerError)
 {
     Code       = code;
     Message    = message;
     Target     = target;
     InnerError = innerError;
 }
コード例 #2
0
        internal static DocumentTranslationError DeserializeDocumentTranslationError(JsonElement element)
        {
            Optional <DocumentTranslationErrorCode> code = default;
            string            message = default;
            Optional <string> target  = default;
            Optional <DocumentTranslationInnerError> innerError = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("code"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    code = new DocumentTranslationErrorCode(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("innerError"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    innerError = DocumentTranslationInnerError.DeserializeDocumentTranslationInnerError(property.Value);
                    continue;
                }
            }
            return(new DocumentTranslationError(Optional.ToNullable(code), message, target.Value, innerError.Value));
        }