internal TranslationStatusResult(string translationId, DateTimeOffset createdOn, DateTimeOffset lastModified, TranslationStatus status, DocumentTranslationError error, StatusSummary summary)
 {
     TranslationId = translationId;
     CreatedOn     = createdOn;
     LastModified  = lastModified;
     Status        = status;
     Error         = error;
     Summary       = summary;
 }
        internal TranslationStatusResult(string translationId, DateTimeOffset createdOn, DateTimeOffset lastModified, TranslationStatus status, StatusSummary summary)
        {
            if (translationId == null)
            {
                throw new ArgumentNullException(nameof(translationId));
            }
            if (summary == null)
            {
                throw new ArgumentNullException(nameof(summary));
            }

            TranslationId = translationId;
            CreatedOn     = createdOn;
            LastModified  = lastModified;
            Status        = status;
            Summary       = summary;
        }
Пример #3
0
 internal DocumentStatusResult(Uri translatedDocumentUri, Uri sourceDocumentUri, DateTimeOffset createdOn, DateTimeOffset lastModified, TranslationStatus status, string translateTo, DocumentTranslationError error, float progress, string documentId, long charactersCharged)
 {
     TranslatedDocumentUri = translatedDocumentUri;
     SourceDocumentUri     = sourceDocumentUri;
     CreatedOn             = createdOn;
     LastModified          = lastModified;
     Status            = status;
     TranslateTo       = translateTo;
     Error             = error;
     Progress          = progress;
     DocumentId        = documentId;
     CharactersCharged = charactersCharged;
 }
Пример #4
0
        internal static DocumentStatusResult DeserializeDocumentStatusResult(JsonElement element)
        {
            Optional <Uri>    path                  = default;
            Uri               sourcePath            = default;
            DateTimeOffset    createdDateTimeUtc    = default;
            DateTimeOffset    lastActionDateTimeUtc = default;
            TranslationStatus status                = default;
            string            to = default;
            Optional <DocumentTranslationError> error = default;
            float           progress         = default;
            string          id               = default;
            Optional <long> characterCharged = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("path"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    path = new Uri(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("sourcePath"))
                {
                    sourcePath = new Uri(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("createdDateTimeUtc"))
                {
                    createdDateTimeUtc = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("lastActionDateTimeUtc"))
                {
                    lastActionDateTimeUtc = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    status = new TranslationStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("to"))
                {
                    to = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = DocumentTranslationError.DeserializeDocumentTranslationError(property.Value);
                    continue;
                }
                if (property.NameEquals("progress"))
                {
                    progress = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("characterCharged"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    characterCharged = property.Value.GetInt64();
                    continue;
                }
            }
            return(new DocumentStatusResult(path.Value, sourcePath, createdDateTimeUtc, lastActionDateTimeUtc, status, to, error.Value, progress, id, characterCharged));
        }
Пример #5
0
        internal DocumentStatusResult(Uri sourceDocumentUri, DateTimeOffset createdOn, DateTimeOffset lastModified, TranslationStatus status, string translateTo, float progress, string documentId)
        {
            if (sourceDocumentUri == null)
            {
                throw new ArgumentNullException(nameof(sourceDocumentUri));
            }
            if (translateTo == null)
            {
                throw new ArgumentNullException(nameof(translateTo));
            }
            if (documentId == null)
            {
                throw new ArgumentNullException(nameof(documentId));
            }

            SourceDocumentUri = sourceDocumentUri;
            CreatedOn         = createdOn;
            LastModified      = lastModified;
            Status            = status;
            TranslateTo       = translateTo;
            Progress          = progress;
            DocumentId        = documentId;
        }