Beispiel #1
0
        /// <summary>
        /// Adds an ArangoDb implementation of identity information stores.
        /// </summary>
        /// <typeparam name="TUser">The type representing a user.</typeparam>
        /// <typeparam name="TRole">The type representing a role.</typeparam>
        /// <typeparam name="TKey">The type of the primary key of the identity document.</typeparam>
        /// <param name="builder">The <see cref="T:Microsoft.AspNetCore.Identity.IdentityBuilder" /> instance this method extends.</param>
        /// <param name="uri"></param>
        /// <param name="databaseName"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        public static IdentityBuilder AddArangoDbStores <TUser, TRole, TKey>(
            this IdentityBuilder builder,
            string uri,
            string databaseName,
            string userName,
            string password)
            where TUser : ArangoIdentityUser, new()
            where TRole : ArangoIdentityRole, new()
            where TKey : IEquatable <TKey>
        {
            var settings = new ArangoDbSettings()
            {
                Uri = uri, Database = databaseName, UserId = userName, Password = password
            };

            ServiceCollectionExtensions.ValidateArangoDbSettings(settings);

            builder.Services.TryAddSingleton(provider => settings);
            builder.AddArangoDbStores <TUser, TRole, TKey>(new ArangoDbContext(settings));
            return(builder);
        }