コード例 #1
0
 internal Skillset(string name, string description, IList <Skill> skills, CognitiveServicesAccount cognitiveServicesAccount, string eTag)
 {
     Name        = name;
     Description = description;
     Skills      = skills;
     CognitiveServicesAccount = cognitiveServicesAccount;
     ETag = eTag;
 }
コード例 #2
0
        internal static Skillset DeserializeSkillset(JsonElement element)
        {
            string                   name              = default;
            string                   description       = default;
            IList <Skill>            skills            = default;
            CognitiveServicesAccount cognitiveServices = default;
            string                   odataEtag         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("skills"))
                {
                    List <Skill> array = new List <Skill>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(Skill.DeserializeSkill(item));
                        }
                    }
                    skills = array;
                    continue;
                }
                if (property.NameEquals("cognitiveServices"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    cognitiveServices = CognitiveServicesAccount.DeserializeCognitiveServicesAccount(property.Value);
                    continue;
                }
                if (property.NameEquals("@odata.etag"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    odataEtag = property.Value.GetString();
                    continue;
                }
            }
            return(new Skillset(name, description, skills, cognitiveServices, odataEtag));
        }