internal static RegistryArtifactProperties FromManifestAttributesManifestReferences(ManifestAttributesManifestReferences reference)
 {
     return(new RegistryArtifactProperties(
                reference.Digest,
                reference.CpuArchitecture,
                reference.OperatingSystem));
 }
Beispiel #2
0
        internal static RegistryArtifactProperties DeserializeRegistryArtifactProperties(JsonElement element)
        {
            Optional <string>         imageName      = default;
            Optional <string>         digest         = default;
            Optional <long>           imageSize      = default;
            Optional <DateTimeOffset> createdTime    = default;
            Optional <DateTimeOffset> lastUpdateTime = default;
            Optional <string>         architecture   = default;
            Optional <string>         os             = default;
            Optional <IReadOnlyList <ManifestAttributesManifestReferences> > references = default;
            Optional <IReadOnlyList <string> > tags = default;
            Optional <ContentProperties>       changeableAttributes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("imageName"))
                {
                    imageName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("manifest"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("digest"))
                        {
                            digest = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("imageSize"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            imageSize = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("createdTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            createdTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("lastUpdateTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            lastUpdateTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("architecture"))
                        {
                            architecture = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("os"))
                        {
                            os = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("references"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ManifestAttributesManifestReferences> array = new List <ManifestAttributesManifestReferences>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ManifestAttributesManifestReferences.DeserializeManifestAttributesManifestReferences(item));
                            }
                            references = array;
                            continue;
                        }
                        if (property0.NameEquals("tags"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            tags = array;
                            continue;
                        }
                        if (property0.NameEquals("changeableAttributes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            changeableAttributes = ContentProperties.DeserializeContentProperties(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new RegistryArtifactProperties(imageName.Value, digest.Value, Optional.ToNullable(imageSize), Optional.ToNullable(createdTime), Optional.ToNullable(lastUpdateTime), architecture.Value, os.Value, Optional.ToList(references), Optional.ToList(tags), changeableAttributes.Value));
        }