internal static ModelVersion DeserializeModelVersion(JsonElement element)
        {
            Optional <string>    stage       = default;
            Optional <string>    datastoreId = default;
            Optional <AssetPath> assetPath   = default;
            Optional <string>    description = default;
            Optional <IDictionary <string, string> > tags       = default;
            Optional <IDictionary <string, string> > properties = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("stage"))
                {
                    stage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("datastoreId"))
                {
                    datastoreId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("assetPath"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    assetPath = AssetPath.DeserializeAssetPath(property.Value);
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    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 ModelVersion(stage.Value, datastoreId.Value, assetPath.Value, description.Value, Optional.ToDictionary(tags), Optional.ToDictionary(properties)));
        }
Пример #2
0
        internal static EnvironmentSpecificationVersion DeserializeEnvironmentSpecificationVersion(JsonElement element)
        {
            Optional <EnvironmentSpecificationType> type   = default;
            Optional <DockerSpecification>          docker = default;
            Optional <string>    condaFile   = default;
            Optional <string>    datastoreId = default;
            Optional <AssetPath> assetPath   = default;
            Optional <string>    description = default;
            Optional <IDictionary <string, string> > tags       = default;
            Optional <IDictionary <string, string> > properties = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = new EnvironmentSpecificationType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("docker"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    docker = DockerSpecification.DeserializeDockerSpecification(property.Value);
                    continue;
                }
                if (property.NameEquals("condaFile"))
                {
                    condaFile = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("datastoreId"))
                {
                    datastoreId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("assetPath"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    assetPath = AssetPath.DeserializeAssetPath(property.Value);
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    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 EnvironmentSpecificationVersion(Optional.ToNullable(type), docker.Value, condaFile.Value, datastoreId.Value, assetPath.Value, description.Value, Optional.ToDictionary(tags), Optional.ToDictionary(properties)));
        }