Exemple #1
0
 internal IdentityProviders(AzureActiveDirectory azureActiveDirectory, Facebook facebook, GitHub gitHub, Google google, LegacyMicrosoftAccount legacyMicrosoftAccount, Twitter twitter, Apple apple, AzureStaticWebApps azureStaticWebApps, IDictionary <string, CustomOpenIdConnectProvider> customOpenIdConnectProviders)
 {
     AzureActiveDirectory = azureActiveDirectory;
     Facebook             = facebook;
     GitHub = gitHub;
     Google = google;
     LegacyMicrosoftAccount = legacyMicrosoftAccount;
     Twitter                      = twitter;
     Apple                        = apple;
     AzureStaticWebApps           = azureStaticWebApps;
     CustomOpenIdConnectProviders = customOpenIdConnectProviders;
 }
        internal static IdentityProviders DeserializeIdentityProviders(JsonElement element)
        {
            Optional <AzureActiveDirectory> azureActiveDirectory = default;
            Optional <Facebook>             facebook             = default;
            Optional <GitHub> gitHub = default;
            Optional <Google> google = default;
            Optional <LegacyMicrosoftAccount> legacyMicrosoftAccount = default;
            Optional <Twitter>            twitter            = default;
            Optional <Apple>              apple              = default;
            Optional <AzureStaticWebApps> azureStaticWebApps = default;
            Optional <IDictionary <string, CustomOpenIdConnectProvider> > customOpenIdConnectProviders = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("azureActiveDirectory"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    azureActiveDirectory = AzureActiveDirectory.DeserializeAzureActiveDirectory(property.Value);
                    continue;
                }
                if (property.NameEquals("facebook"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    facebook = Facebook.DeserializeFacebook(property.Value);
                    continue;
                }
                if (property.NameEquals("gitHub"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    gitHub = GitHub.DeserializeGitHub(property.Value);
                    continue;
                }
                if (property.NameEquals("google"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    google = Google.DeserializeGoogle(property.Value);
                    continue;
                }
                if (property.NameEquals("legacyMicrosoftAccount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    legacyMicrosoftAccount = LegacyMicrosoftAccount.DeserializeLegacyMicrosoftAccount(property.Value);
                    continue;
                }
                if (property.NameEquals("twitter"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    twitter = Twitter.DeserializeTwitter(property.Value);
                    continue;
                }
                if (property.NameEquals("apple"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    apple = Apple.DeserializeApple(property.Value);
                    continue;
                }
                if (property.NameEquals("azureStaticWebApps"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    azureStaticWebApps = AzureStaticWebApps.DeserializeAzureStaticWebApps(property.Value);
                    continue;
                }
                if (property.NameEquals("customOpenIdConnectProviders"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, CustomOpenIdConnectProvider> dictionary = new Dictionary <string, CustomOpenIdConnectProvider>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, CustomOpenIdConnectProvider.DeserializeCustomOpenIdConnectProvider(property0.Value));
                    }
                    customOpenIdConnectProviders = dictionary;
                    continue;
                }
            }
            return(new IdentityProviders(azureActiveDirectory.Value, facebook.Value, gitHub.Value, google.Value, legacyMicrosoftAccount.Value, twitter.Value, apple.Value, azureStaticWebApps.Value, Optional.ToDictionary(customOpenIdConnectProviders)));
        }