Exemplo n.º 1
0
 internal OciManifest(OciBlobDescriptor config, IList <OciBlobDescriptor> layers, OciAnnotations annotations, int?schemaVersion)
 {
     Config        = config;
     Layers        = layers;
     Annotations   = annotations;
     SchemaVersion = schemaVersion;
 }
Exemplo n.º 2
0
 internal OciBlobDescriptor(string mediaType, long?size, string digest, IList <Uri> urls, OciAnnotations annotations)
 {
     MediaType   = mediaType;
     Size        = size;
     Digest      = digest;
     Urls        = urls;
     Annotations = annotations;
 }
        internal static OciBlobDescriptor DeserializeOciBlobDescriptor(JsonElement element)
        {
            Optional <string>         mediaType   = default;
            Optional <long>           size        = default;
            Optional <string>         digest      = default;
            Optional <IList <Uri> >   urls        = default;
            Optional <OciAnnotations> annotations = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("mediaType"))
                {
                    mediaType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("size"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    size = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("digest"))
                {
                    digest = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("urls"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Uri> array = new List <Uri>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(new Uri(item.GetString()));
                    }
                    urls = array;
                    continue;
                }
                if (property.NameEquals("annotations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        annotations = null;
                        continue;
                    }
                    annotations = OciAnnotations.DeserializeOciAnnotations(property.Value);
                    continue;
                }
            }
            return(new OciBlobDescriptor(mediaType.Value, Optional.ToNullable(size), digest.Value, Optional.ToList(urls), annotations.Value));
        }
Exemplo n.º 4
0
        internal static OciManifest DeserializeOciManifest(JsonElement element)
        {
            Optional <OciBlobDescriptor>          config      = default;
            Optional <IList <OciBlobDescriptor> > layers      = default;
            Optional <OciAnnotations>             annotations = default;
            Optional <int> schemaVersion = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("config"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    config = OciBlobDescriptor.DeserializeOciBlobDescriptor(property.Value);
                    continue;
                }
                if (property.NameEquals("layers"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <OciBlobDescriptor> array = new List <OciBlobDescriptor>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(OciBlobDescriptor.DeserializeOciBlobDescriptor(item));
                    }
                    layers = array;
                    continue;
                }
                if (property.NameEquals("annotations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        annotations = null;
                        continue;
                    }
                    annotations = OciAnnotations.DeserializeOciAnnotations(property.Value);
                    continue;
                }
                if (property.NameEquals("schemaVersion"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    schemaVersion = property.Value.GetInt32();
                    continue;
                }
            }
            return(new OciManifest(config.Value, Optional.ToList(layers), annotations.Value, Optional.ToNullable(schemaVersion)));
        }