Exemple #1
0
        internal static LanguageDetectionSkill DeserializeLanguageDetectionSkill(JsonElement element)
        {
            LanguageDetectionSkill result = new LanguageDetectionSkill();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@odata.type"))
                {
                    result.ODataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("context"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Context = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.Inputs.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item));
                    }
                    continue;
                }
                if (property.NameEquals("outputs"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.Outputs.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item));
                    }
                    continue;
                }
            }
            return(result);
        }
        internal static SearchIndexerSkill DeserializeSearchIndexerSkill(JsonElement element)
        {
            if (element.TryGetProperty("@odata.type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "#Microsoft.Skills.Custom.WebApiSkill": return(WebApiSkill.DeserializeWebApiSkill(element));

                case "#Microsoft.Skills.Text.EntityRecognitionSkill": return(EntityRecognitionSkill.DeserializeEntityRecognitionSkill(element));

                case "#Microsoft.Skills.Text.KeyPhraseExtractionSkill": return(KeyPhraseExtractionSkill.DeserializeKeyPhraseExtractionSkill(element));

                case "#Microsoft.Skills.Text.LanguageDetectionSkill": return(LanguageDetectionSkill.DeserializeLanguageDetectionSkill(element));

                case "#Microsoft.Skills.Text.MergeSkill": return(MergeSkill.DeserializeMergeSkill(element));

                case "#Microsoft.Skills.Text.SentimentSkill": return(SentimentSkill.DeserializeSentimentSkill(element));

                case "#Microsoft.Skills.Text.SplitSkill": return(SplitSkill.DeserializeSplitSkill(element));

                case "#Microsoft.Skills.Text.TranslationSkill": return(TextTranslationSkill.DeserializeTextTranslationSkill(element));

                case "#Microsoft.Skills.Util.ConditionalSkill": return(ConditionalSkill.DeserializeConditionalSkill(element));

                case "#Microsoft.Skills.Util.ShaperSkill": return(ShaperSkill.DeserializeShaperSkill(element));

                case "#Microsoft.Skills.Vision.ImageAnalysisSkill": return(ImageAnalysisSkill.DeserializeImageAnalysisSkill(element));

                case "#Microsoft.Skills.Vision.OcrSkill": return(OcrSkill.DeserializeOcrSkill(element));
                }
            }
            string odataType   = default;
            string name        = default;
            string description = default;
            string context     = default;
            IList <InputFieldMappingEntry>  inputs  = default;
            IList <OutputFieldMappingEntry> outputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@odata.type"))
                {
                    odataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("context"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    context = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <InputFieldMappingEntry> array = new List <InputFieldMappingEntry>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item));
                        }
                    }
                    inputs = array;
                    continue;
                }
                if (property.NameEquals("outputs"))
                {
                    List <OutputFieldMappingEntry> array = new List <OutputFieldMappingEntry>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item));
                        }
                    }
                    outputs = array;
                    continue;
                }
            }
            return(new SearchIndexerSkill(odataType, name, description, context, inputs, outputs));
        }
        internal static Skill DeserializeSkill(JsonElement element)
        {
            if (element.TryGetProperty("@odata.type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "#Microsoft.Skills.Custom.WebApiSkill": return(WebApiSkill.DeserializeWebApiSkill(element));

                case "#Microsoft.Skills.Text.EntityRecognitionSkill": return(EntityRecognitionSkill.DeserializeEntityRecognitionSkill(element));

                case "#Microsoft.Skills.Text.KeyPhraseExtractionSkill": return(KeyPhraseExtractionSkill.DeserializeKeyPhraseExtractionSkill(element));

                case "#Microsoft.Skills.Text.LanguageDetectionSkill": return(LanguageDetectionSkill.DeserializeLanguageDetectionSkill(element));

                case "#Microsoft.Skills.Text.MergeSkill": return(MergeSkill.DeserializeMergeSkill(element));

                case "#Microsoft.Skills.Text.SentimentSkill": return(SentimentSkill.DeserializeSentimentSkill(element));

                case "#Microsoft.Skills.Text.SplitSkill": return(SplitSkill.DeserializeSplitSkill(element));

                case "#Microsoft.Skills.Text.TranslationSkill": return(TextTranslationSkill.DeserializeTextTranslationSkill(element));

                case "#Microsoft.Skills.Util.ConditionalSkill": return(ConditionalSkill.DeserializeConditionalSkill(element));

                case "#Microsoft.Skills.Util.ShaperSkill": return(ShaperSkill.DeserializeShaperSkill(element));

                case "#Microsoft.Skills.Vision.ImageAnalysisSkill": return(ImageAnalysisSkill.DeserializeImageAnalysisSkill(element));

                case "#Microsoft.Skills.Vision.OcrSkill": return(OcrSkill.DeserializeOcrSkill(element));
                }
            }
            Skill result = new Skill();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@odata.type"))
                {
                    result.ODataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("context"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Context = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.Inputs.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item));
                    }
                    continue;
                }
                if (property.NameEquals("outputs"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.Outputs.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item));
                    }
                    continue;
                }
            }
            return(result);
        }