コード例 #1
0
 internal TextTranslationSkill(string odataType, string name, string description, string context, IList <InputFieldMappingEntry> inputs, IList <OutputFieldMappingEntry> outputs, TextTranslationSkillLanguage defaultToLanguageCode, TextTranslationSkillLanguage?defaultFromLanguageCode, TextTranslationSkillLanguage?suggestedFrom) : base(odataType, name, description, context, inputs, outputs)
 {
     DefaultToLanguageCode   = defaultToLanguageCode;
     DefaultFromLanguageCode = defaultFromLanguageCode;
     SuggestedFrom           = suggestedFrom;
     OdataType = odataType ?? "#Microsoft.Skills.Text.TranslationSkill";
 }
コード例 #2
0
        public TextTranslationSkill(IEnumerable <InputFieldMappingEntry> inputs, IEnumerable <OutputFieldMappingEntry> outputs, TextTranslationSkillLanguage defaultToLanguageCode) : base(inputs, outputs)
        {
            if (inputs == null)
            {
                throw new ArgumentNullException(nameof(inputs));
            }
            if (outputs == null)
            {
                throw new ArgumentNullException(nameof(outputs));
            }

            DefaultToLanguageCode = defaultToLanguageCode;
            OdataType             = "#Microsoft.Skills.Text.TranslationSkill";
        }
コード例 #3
0
        internal static TextTranslationSkill DeserializeTextTranslationSkill(JsonElement element)
        {
            TextTranslationSkillLanguage defaultToLanguageCode   = default;
            TextTranslationSkillLanguage?defaultFromLanguageCode = default;
            TextTranslationSkillLanguage?suggestedFrom           = default;
            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("defaultToLanguageCode"))
                {
                    defaultToLanguageCode = new TextTranslationSkillLanguage(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("defaultFromLanguageCode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    defaultFromLanguageCode = new TextTranslationSkillLanguage(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("suggestedFrom"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    suggestedFrom = new TextTranslationSkillLanguage(property.Value.GetString());
                    continue;
                }
                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 TextTranslationSkill(odataType, name, description, context, inputs, outputs, defaultToLanguageCode, defaultFromLanguageCode, suggestedFrom));
        }