internal ResourceTypeAliasPath(string path, IReadOnlyList <string> apiVersions, ResourceTypeAliasPattern pattern, ResourceTypeAliasPathMetadata metadata)
 {
     Path        = path;
     ApiVersions = apiVersions;
     Pattern     = pattern;
     Metadata    = metadata;
 }
 internal ResourceTypeAlias(string name, IReadOnlyList <ResourceTypeAliasPath> paths, ResourceTypeAliasType?resourceTypeAliasType, string defaultPath, ResourceTypeAliasPattern defaultPattern, ResourceTypeAliasPathMetadata defaultMetadata)
 {
     Name  = name;
     Paths = paths;
     ResourceTypeAliasType = resourceTypeAliasType;
     DefaultPath           = defaultPath;
     DefaultPattern        = defaultPattern;
     DefaultMetadata       = defaultMetadata;
 }
예제 #3
0
        internal static ResourceTypeAliasPath DeserializeResourceTypeAliasPath(JsonElement element)
        {
            Optional <string> path = default;
            Optional <IReadOnlyList <string> >       apiVersions = default;
            Optional <ResourceTypeAliasPattern>      pattern     = default;
            Optional <ResourceTypeAliasPathMetadata> metadata    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("path"))
                {
                    path = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("apiVersions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    apiVersions = array;
                    continue;
                }
                if (property.NameEquals("pattern"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    pattern = ResourceTypeAliasPattern.DeserializeResourceTypeAliasPattern(property.Value);
                    continue;
                }
                if (property.NameEquals("metadata"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    metadata = ResourceTypeAliasPathMetadata.DeserializeResourceTypeAliasPathMetadata(property.Value);
                    continue;
                }
            }
            return(new ResourceTypeAliasPath(path.Value, Optional.ToList(apiVersions), pattern.Value, metadata.Value));
        }
        internal static ResourceTypeAlias DeserializeResourceTypeAlias(JsonElement element)
        {
            Optional <string> name = default;
            Optional <IReadOnlyList <ResourceTypeAliasPath> > paths = default;
            Optional <ResourceTypeAliasType> type = default;
            Optional <string> defaultPath         = default;
            Optional <ResourceTypeAliasPattern>      defaultPattern  = default;
            Optional <ResourceTypeAliasPathMetadata> defaultMetadata = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("paths"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ResourceTypeAliasPath> array = new List <ResourceTypeAliasPath>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ResourceTypeAliasPath.DeserializeResourceTypeAliasPath(item));
                    }
                    paths = array;
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = property.Value.GetString().ToResourceTypeAliasType();
                    continue;
                }
                if (property.NameEquals("defaultPath"))
                {
                    defaultPath = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("defaultPattern"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    defaultPattern = ResourceTypeAliasPattern.DeserializeResourceTypeAliasPattern(property.Value);
                    continue;
                }
                if (property.NameEquals("defaultMetadata"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    defaultMetadata = ResourceTypeAliasPathMetadata.DeserializeResourceTypeAliasPathMetadata(property.Value);
                    continue;
                }
            }
            return(new ResourceTypeAlias(name.Value, Optional.ToList(paths), Optional.ToNullable(type), defaultPath.Value, defaultPattern.Value, defaultMetadata.Value));
        }