示例#1
0
        internal static ProviderResourceType DeserializeProviderResourceType(JsonElement element)
        {
            Optional <string> resourceType = default;
            Optional <IReadOnlyList <string> >               locations   = default;
            Optional <IReadOnlyList <AliasType> >            aliases     = default;
            Optional <IReadOnlyList <string> >               apiVersions = default;
            Optional <IReadOnlyDictionary <string, string> > properties  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("resourceType"))
                {
                    resourceType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("locations"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    locations = array;
                    continue;
                }
                if (property.NameEquals("aliases"))
                {
                    List <AliasType> array = new List <AliasType>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(AliasType.DeserializeAliasType(item));
                    }
                    aliases = array;
                    continue;
                }
                if (property.NameEquals("apiVersions"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    apiVersions = array;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    properties = dictionary;
                    continue;
                }
            }
            return(new ProviderResourceType(resourceType.Value, Optional.ToList(locations), Optional.ToList(aliases), Optional.ToList(apiVersions), Optional.ToDictionary(properties)));
        }
示例#2
0
        internal static ProviderResourceType DeserializeProviderResourceType(JsonElement element)
        {
            string resourceType = default;
            IReadOnlyList <string>               locations   = default;
            IReadOnlyList <AliasType>            aliases     = default;
            IReadOnlyList <string>               apiVersions = default;
            IReadOnlyDictionary <string, string> properties  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("resourceType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    resourceType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("locations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    locations = array;
                    continue;
                }
                if (property.NameEquals("aliases"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <AliasType> array = new List <AliasType>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(AliasType.DeserializeAliasType(item));
                        }
                    }
                    aliases = array;
                    continue;
                }
                if (property.NameEquals("apiVersions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    apiVersions = array;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.Value.ValueKind == JsonValueKind.Null)
                        {
                            dictionary.Add(property0.Name, null);
                        }
                        else
                        {
                            dictionary.Add(property0.Name, property0.Value.GetString());
                        }
                    }
                    properties = dictionary;
                    continue;
                }
            }
            return(new ProviderResourceType(resourceType, locations, aliases, apiVersions, properties));
        }