Example #1
0
        internal static SharingUpdate DeserializeSharingUpdate(JsonElement element)
        {
            SharingUpdateOperationTypes             operationType = default;
            Optional <IList <SharingProfileGroup> > groups        = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("operationType"))
                {
                    operationType = new SharingUpdateOperationTypes(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("groups"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SharingProfileGroup> array = new List <SharingProfileGroup>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SharingProfileGroup.DeserializeSharingProfileGroup(item));
                    }
                    groups = array;
                    continue;
                }
            }
            return(new SharingUpdate(operationType, Optional.ToList(groups)));
        }
Example #2
0
        internal static SharingProfile DeserializeSharingProfile(JsonElement element)
        {
            Optional <GallerySharingPermissionTypes>        permissions = default;
            Optional <IReadOnlyList <SharingProfileGroup> > groups      = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("permissions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    permissions = new GallerySharingPermissionTypes(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("groups"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SharingProfileGroup> array = new List <SharingProfileGroup>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SharingProfileGroup.DeserializeSharingProfileGroup(item));
                    }
                    groups = array;
                    continue;
                }
            }
            return(new SharingProfile(Optional.ToNullable(permissions), Optional.ToList(groups)));
        }