Exemplo n.º 1
0
        internal static SasDefinitionBundle DeserializeSasDefinitionBundle(JsonElement element)
        {
            Optional <string>                  id                 = default;
            Optional <string>                  sid                = default;
            Optional <string>                  templateUri        = default;
            Optional <SasTokenType>            sasType            = default;
            Optional <string>                  validityPeriod     = default;
            Optional <SasDefinitionAttributes> attributes         = default;
            Optional <IReadOnlyDictionary <string, string> > tags = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sid"))
                {
                    sid = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("templateUri"))
                {
                    templateUri = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sasType"))
                {
                    sasType = new SasTokenType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("validityPeriod"))
                {
                    validityPeriod = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("attributes"))
                {
                    attributes = SasDefinitionAttributes.DeserializeSasDefinitionAttributes(property.Value);
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    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;
                }
            }
            return(new SasDefinitionBundle(id.Value, sid.Value, templateUri.Value, Optional.ToNullable(sasType), validityPeriod.Value, attributes.Value, Optional.ToDictionary(tags)));
        }
        internal static DeletedSasDefinitionItem DeserializeDeletedSasDefinitionItem(JsonElement element)
        {
            Optional <string>                  recoveryId         = default;
            Optional <DateTimeOffset>          scheduledPurgeDate = default;
            Optional <DateTimeOffset>          deletedDate        = default;
            Optional <string>                  id                 = default;
            Optional <string>                  sid                = default;
            Optional <SasDefinitionAttributes> attributes         = default;
            Optional <IReadOnlyDictionary <string, string> > tags = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("recoveryId"))
                {
                    recoveryId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("scheduledPurgeDate"))
                {
                    scheduledPurgeDate = property.Value.GetDateTimeOffset("U");
                    continue;
                }
                if (property.NameEquals("deletedDate"))
                {
                    deletedDate = property.Value.GetDateTimeOffset("U");
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sid"))
                {
                    sid = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("attributes"))
                {
                    attributes = SasDefinitionAttributes.DeserializeSasDefinitionAttributes(property.Value);
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    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;
                }
            }
            return(new DeletedSasDefinitionItem(id.Value, sid.Value, attributes.Value, Optional.ToDictionary(tags), recoveryId.Value, Optional.ToNullable(scheduledPurgeDate), Optional.ToNullable(deletedDate)));
        }
        internal static SasDefinitionItem DeserializeSasDefinitionItem(JsonElement element)
        {
            Optional <string> id  = default;
            Optional <string> sid = default;
            Optional <SasDefinitionAttributes> attributes         = default;
            Optional <IReadOnlyDictionary <string, string> > tags = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sid"))
                {
                    sid = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("attributes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    attributes = SasDefinitionAttributes.DeserializeSasDefinitionAttributes(property.Value);
                    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;
                }
            }
            return(new SasDefinitionItem(id.Value, sid.Value, attributes.Value, Optional.ToDictionary(tags)));
        }
        internal static DeletedSasDefinitionBundle DeserializeDeletedSasDefinitionBundle(JsonElement element)
        {
            Optional <string>                  recoveryId         = default;
            Optional <DateTimeOffset>          scheduledPurgeDate = default;
            Optional <DateTimeOffset>          deletedDate        = default;
            Optional <string>                  id                 = default;
            Optional <string>                  sid                = default;
            Optional <string>                  templateUri        = default;
            Optional <SasTokenType>            sasType            = default;
            Optional <string>                  validityPeriod     = default;
            Optional <SasDefinitionAttributes> attributes         = default;
            Optional <IReadOnlyDictionary <string, string> > tags = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("recoveryId"))
                {
                    recoveryId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("scheduledPurgeDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    scheduledPurgeDate = property.Value.GetDateTimeOffset("U");
                    continue;
                }
                if (property.NameEquals("deletedDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    deletedDate = property.Value.GetDateTimeOffset("U");
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sid"))
                {
                    sid = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("templateUri"))
                {
                    templateUri = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("sasType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sasType = new SasTokenType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("validityPeriod"))
                {
                    validityPeriod = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("attributes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    attributes = SasDefinitionAttributes.DeserializeSasDefinitionAttributes(property.Value);
                    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;
                }
            }
            return(new DeletedSasDefinitionBundle(id.Value, sid.Value, templateUri.Value, Optional.ToNullable(sasType), validityPeriod.Value, attributes.Value, Optional.ToDictionary(tags), recoveryId.Value, Optional.ToNullable(scheduledPurgeDate), Optional.ToNullable(deletedDate)));
        }