Skip to content

Commit

Permalink
samples cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
maririos committed Mar 3, 2021
1 parent 9f57aec commit 4e02817
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,10 @@ public void DocumentStatus()
string apiKey = TestEnvironment.ApiKey;
Uri sourceUrl = new Uri(TestEnvironment.SourceUrl);
Uri targetUrl = new Uri(TestEnvironment.TargetUrl);
Uri glossaryUrl = new Uri(TestEnvironment.GlossaryUrl);

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

var glossaries = new List<TranslationGlossary>()
{
new TranslationGlossary(glossaryUrl)
};

var options = new TranslationOperationOptions
{
StorageType = StorageType.Folder
};

DocumentTranslationOperation operation = client.StartTranslation(sourceUrl, targetUrl, "it", glossaries, options);
DocumentTranslationOperation operation = client.StartTranslation(sourceUrl, targetUrl, "it");

var documentscompleted = new HashSet<string>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,10 @@ public async Task DocumentStatusAsync()
string apiKey = TestEnvironment.ApiKey;
Uri sourceUrl = new Uri(TestEnvironment.SourceUrl);
Uri targetUrl = new Uri(TestEnvironment.TargetUrl);
Uri glossaryUrl = new Uri(TestEnvironment.GlossaryUrl);

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

var glossaries = new List<TranslationGlossary>()
{
new TranslationGlossary(glossaryUrl)
};

var options = new TranslationOperationOptions
{
StorageType = StorageType.Folder
};

DocumentTranslationOperation operation = client.StartTranslation(sourceUrl, targetUrl, "it", glossaries, options);
DocumentTranslationOperation operation = client.StartTranslation(sourceUrl, targetUrl, "it");

var documentscompleted = new HashSet<string>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ public void OperationsHistory()
}
}

Console.WriteLine($"# of operations: {operationsCount}\nTotal Documents: {totalDocs}\n"
+ $"DocumentsSucceeded: {docsSucceeded}\n"
+ $"Cancelled Documents: {docsCancelled}");
Console.WriteLine($"# of operations: {operationsCount}");
Console.WriteLine($"Total Documents: {totalDocs}");
Console.WriteLine($"DocumentsSucceeded: {docsSucceeded}");
Console.WriteLine($"Cancelled Documents: {docsCancelled}");

Console.WriteLine($"Largest operation is {largestOperation.Id} and has the documents:");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ public async Task OperationsHistoryAsync()
}
}

Console.WriteLine($"# of operations: {operationsCount}\nTotal Documents: {totalDocs}\n"
+ $"DocumentsSucceeded: {docsSucceeded}\n"
+ $"Cancelled Documents: {docsCancelled}");
Console.WriteLine($"# of operations: {operationsCount}");
Console.WriteLine($"Total Documents: {totalDocs}");
Console.WriteLine($"DocumentsSucceeded: {docsSucceeded}");
Console.WriteLine($"Cancelled Documents: {docsCancelled}");

Console.WriteLine($"Largest operation is {largestOperation} and has the documents:");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public void TranslateOperation()
string apiKey = TestEnvironment.ApiKey;
Uri sourceUrl = new Uri(TestEnvironment.SourceUrl);
Uri targetUrl = new Uri(TestEnvironment.TargetUrl);
Uri glossaryUrl = new Uri(TestEnvironment.GlossaryUrl);

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public async Task TranslateOperationAsync()
string apiKey = TestEnvironment.ApiKey;
Uri sourceUrl = new Uri(TestEnvironment.SourceUrl);
Uri targetUrl = new Uri(TestEnvironment.TargetUrl);
Uri glossaryUrl = new Uri(TestEnvironment.GlossaryUrl);

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,30 @@ public void TranslateOperationComplex()
{
string endpoint = TestEnvironment.Endpoint;
string apiKey = TestEnvironment.ApiKey;
string sourceUrl = TestEnvironment.SourceUrl;
string targetUrl = TestEnvironment.TargetUrl;
string sourceUrl1 = TestEnvironment.SourceUrl;
string sourceUrl2 = TestEnvironment.SourceUrl;
string targetUrl1 = TestEnvironment.TargetUrl;
string targetUrl2 = TestEnvironment.TargetUrl;
Uri glossaryUrl = new Uri(TestEnvironment.GlossaryUrl);

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

var input1 = new TranslationConfiguration(
new SourceConfiguration(sourceUrl),
new List<TargetConfiguration>()
{
new TargetConfiguration(targetUrl, "it", new List<TranslationGlossary> {new TranslationGlossary(glossaryUrl)})
},
StorageType.Folder);
var glossaries = new List<TranslationGlossary>() { new TranslationGlossary(glossaryUrl) };

var input2 = new TranslationConfiguration(
new SourceConfiguration(targetUrl),
new List<TargetConfiguration>()
{
new TargetConfiguration(sourceUrl, "en", new List<TranslationGlossary> {new TranslationGlossary(glossaryUrl)})
},
StorageType.Folder);
var configuration1 = new TranslationConfiguration(
source: new SourceConfiguration(sourceUrl1),
targets: new List<TargetConfiguration>() { new TargetConfiguration(targetUrl1, "it", glossaries) },
storageType: StorageType.Folder);

var configuration2 = new TranslationConfiguration(
source: new SourceConfiguration(sourceUrl2),
targets: new List<TargetConfiguration>() { new TargetConfiguration(targetUrl2, "it", glossaries) },
storageType: StorageType.Folder);

var inputs = new List<TranslationConfiguration>()
{
input1,
input2
configuration1,
configuration2
};

DocumentTranslationOperation operation = client.StartTranslation(inputs);
Expand Down

0 comments on commit 4e02817

Please sign in to comment.