예제 #1
0
        internal static PreAuthorizedApplication DeserializePreAuthorizedApplication(JsonElement element)
        {
            Optional <string> appId = default;
            Optional <IList <PreAuthorizedApplicationPermission> > permissions = default;
            Optional <IList <PreAuthorizedApplicationExtension> >  extensions  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("appId"))
                {
                    appId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("permissions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <PreAuthorizedApplicationPermission> array = new List <PreAuthorizedApplicationPermission>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(PreAuthorizedApplicationPermission.DeserializePreAuthorizedApplicationPermission(item));
                    }
                    permissions = array;
                    continue;
                }
                if (property.NameEquals("extensions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <PreAuthorizedApplicationExtension> array = new List <PreAuthorizedApplicationExtension>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(PreAuthorizedApplicationExtension.DeserializePreAuthorizedApplicationExtension(item));
                    }
                    extensions = array;
                    continue;
                }
            }
            return(new PreAuthorizedApplication(appId.Value, Optional.ToList(permissions), Optional.ToList(extensions)));
        }
예제 #2
0
        internal static PreAuthorizedApplication DeserializePreAuthorizedApplication(JsonElement element)
        {
            string appId = default;
            IList <PreAuthorizedApplicationPermission> permissions = default;
            IList <PreAuthorizedApplicationExtension>  extensions  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("appId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    appId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("permissions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <PreAuthorizedApplicationPermission> array = new List <PreAuthorizedApplicationPermission>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(PreAuthorizedApplicationPermission.DeserializePreAuthorizedApplicationPermission(item));
                        }
                    }
                    permissions = array;
                    continue;
                }
                if (property.NameEquals("extensions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <PreAuthorizedApplicationExtension> array = new List <PreAuthorizedApplicationExtension>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(PreAuthorizedApplicationExtension.DeserializePreAuthorizedApplicationExtension(item));
                        }
                    }
                    extensions = array;
                    continue;
                }
            }
            return(new PreAuthorizedApplication(appId, permissions, extensions));
        }