Example #1
0
        internal static TextAnalyticsError ReadTextAnalyticsError(JsonElement element)
        {
            string             errorCode  = default;
            string             message    = default;
            string             target     = default;
            TextAnalyticsError innerError = default;

            foreach (JsonProperty property in element.EnumerateObject())
            {
                if (property.NameEquals("code"))
                {
                    errorCode = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("message"))
                {
                    message = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("target"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    target = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("innererror"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    innerError = ReadTextAnalyticsError(property.Value);
                    continue;
                }
            }

            // Return the innermost error, which should be only one level down.
            return(innerError.ErrorCode == default ? new TextAnalyticsError(errorCode, message, target) : innerError);
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of <see cref="TextAnalytics.RecognizeLinkedEntitiesResult"/> for mocking purposes.
 /// </summary>
 /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param>
 /// <param name="error">Sets the <see cref="TextAnalyticsResult.Error"/> property.</param>
 /// <returns>A new instance of <see cref="TextAnalytics.RecognizeLinkedEntitiesResult"/> for mocking purposes.</returns>
 public static RecognizeLinkedEntitiesResult RecognizeLinkedEntitiesResult(string id, TextAnalyticsError error)
 {
     return(new RecognizeLinkedEntitiesResult(id, error));
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of <see cref="TextAnalytics.ExtractKeyPhrasesResult"/> for mocking purposes.
 /// </summary>
 /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param>
 /// <param name="error">Sets the <see cref="TextAnalyticsResult.Error"/> property.</param>
 /// <returns>A new instance of <see cref="TextAnalytics.ExtractKeyPhrasesResult"/> for mocking purposes.</returns>
 public static ExtractKeyPhrasesResult ExtractKeyPhrasesResult(string id, TextAnalyticsError error)
 {
     return(new ExtractKeyPhrasesResult(id, error));
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of <see cref="TextAnalytics.DetectLanguageResult"/> for mocking purposes.
 /// </summary>
 /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param>
 /// <param name="error">Sets the <see cref="TextAnalyticsResult.Error"/> property.</param>
 /// <returns>A new instance of <see cref="TextAnalytics.DetectLanguageResult"/> for mocking purposes.</returns>
 public static DetectLanguageResult DetectLanguageResult(string id, TextAnalyticsError error)
 {
     return(new DetectLanguageResult(id, error));
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of <see cref="TextAnalytics.AnalyzeSentimentResult"/> for mocking purposes.
 /// </summary>
 /// <param name="id">Sets the <see cref="TextAnalyticsResult.Id"/> property.</param>
 /// <param name="error">Sets the <see cref="TextAnalyticsResult.Error"/> property.</param>
 /// <returns>A new instance of <see cref="TextAnalytics.AnalyzeSentimentResult"/> for mocking purposes.</returns>
 public static AnalyzeSentimentResult AnalyzeSentimentResult(string id, TextAnalyticsError error)
 {
     return(new AnalyzeSentimentResult(id, error));
 }
 internal AnalyzeHealthcareEntitiesResult(string id, TextAnalyticsError error) : base(id, error)
 {
 }
Example #7
0
 internal RecognizePiiEntitiesResult(string id, TextAnalyticsError error) : base(id, error)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentHealthcareResult"/> class.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="textAnalyticsError"></param>
 internal DocumentHealthcareResult(string id, TextAnalyticsError textAnalyticsError)
 {
     Id = id;
     TextAnalyticsError = textAnalyticsError;
 }
Example #9
0
 internal ExtractKeyPhrasesResult(string id, TextAnalyticsError error) : base(id, error)
 {
 }
 internal AnalyzeSentimentResult(string id, TextAnalyticsError error) : base(id, error)
 {
 }
Example #11
0
 internal DetectLanguageResult(string id, TextAnalyticsError error) : base(id, error)
 {
 }
Example #12
0
 internal SingleCategoryClassifyResult(string id, TextAnalyticsError error) : base(id, error)
 {
 }
Example #13
0
 internal ExtractSummaryResult(string id, TextAnalyticsError error) : base(id, error)
 {
 }