Exemple #1
0
        internal static GitHubProvider DeserializeGitHubProvider(JsonElement element)
        {
            Optional <bool> enabled = default;
            Optional <ClientRegistration> registration = default;
            Optional <LoginScopes>        login        = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("enabled"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    enabled = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("registration"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    registration = ClientRegistration.DeserializeClientRegistration(property.Value);
                    continue;
                }
                if (property.NameEquals("login"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    login = Models.LoginScopes.DeserializeLoginScopes(property.Value);
                    continue;
                }
            }
            return(new GitHubProvider(Optional.ToNullable(enabled), registration.Value, login.Value));
        }
 internal GitHubProvider(bool?enabled, ClientRegistration registration, LoginScopes login)
 {
     Enabled      = enabled;
     Registration = registration;
     Login        = login;
 }