コード例 #1
0
        public static IJpProjectConfigurationBuilder AddSsoContext <TContext>(this IJpProjectConfigurationBuilder services)
            where TContext : class, ISsoContext, IEventStoreContext

        {
            services.Services.TryAddScoped <IEventStore, SqlEventStore>();
            services.Services.TryAddScoped <IUnitOfWork, UnitOfWork>();
            services.Services.AddScoped <ISsoContext, TContext>();
            services.Services.TryAddScoped <IEventStoreContext>(s => s.GetService <TContext>());
            services.Services.TryAddScoped <IJpEntityFrameworkStore>(x => x.GetRequiredService <TContext>());
            services.Services.AddStores();
            return(services);
        }
コード例 #2
0
        /// <summary>
        /// Configure IdentityServer4 Administration services
        /// </summary>
        public static IJpProjectConfigurationBuilder ConfigureJpAdmin <TUser>(this IJpProjectConfigurationBuilder builder)
            where TUser : class, ISystemUser
        {
            // Domain Bus (Mediator)
            builder.Services.TryAddScoped <IMediatorHandler, InMemoryBus>();
            builder.Services.TryAddScoped <ISystemUser, TUser>();
            builder.Services
            .AddApplicationServices()
            .AddDomainEventsServices()
            .AddDomainCommandsServices();

            return(builder);
        }
コード例 #3
0
        public static IJpProjectConfigurationBuilder SetupDefaultIdentityServerContext <TContext>(
            this IJpProjectConfigurationBuilder services)
            where TContext : IPersistedGrantDbContext, IConfigurationDbContext
        {
            // Configure identityserver4 default database
            var operationalStoreOptions = new OperationalStoreOptions();
            var storeOptions            = new ConfigurationStoreOptions();

            services.Services.AddSingleton(operationalStoreOptions);
            services.Services.AddSingleton(storeOptions);
            services.Services.TryAddScoped <IPersistedGrantDbContext>(x => x.GetRequiredService <TContext>());
            services.Services.TryAddScoped <IConfigurationDbContext>(x => x.GetRequiredService <TContext>());
            return(services);
        }
コード例 #4
0
        /// <summary>
        /// Configure SSO Services
        /// </summary>
        /// <typeparam name="THttpUser">Implementation of ISystemUser</typeparam>
        /// <returns></returns>
        public static IJpProjectConfigurationBuilder ConfigureSso <THttpUser>(this IJpProjectConfigurationBuilder builder)
            where THttpUser : class, ISystemUser
        {
            builder.Services.TryAddScoped <IMediatorHandler, InMemoryBus>();
            builder.Services.TryAddScoped <ISystemUser, THttpUser>();
            builder.Services.AddScoped <IEventSink, IdentityServerEventStore>();
            builder.Services.AddScoped <IStorage, StorageService>();
            builder.Services
            .AddApplicationServices()
            .AddDomainEvents()
            .AddDomainCommands();

            return(new JpProjectBuilder(builder.Services));
        }
コード例 #5
0
        public static IJpProjectConfigurationBuilder AddJpAdminContext(this IJpProjectConfigurationBuilder services, Action <DbContextOptionsBuilder> optionsAction, JpDatabaseOptions options = null)
        {
            if (options == null)
            {
                options = new JpDatabaseOptions();
            }

            RegisterStorageServices(services.Services);

            services.Services.TryAddScoped <IUnitOfWork, UnitOfWork>();

            services.Services.AddDbContext <JpProjectAdminUiContext>(optionsAction);
            services.Services.AddScoped <IJpEntityFrameworkStore>(x => x.GetService <JpProjectAdminUiContext>());
            services.Services.AddScoped <IConfigurationDbContext>(x => x.GetService <JpProjectAdminUiContext>());
            services.Services.AddScoped <IPersistedGrantDbContext>(x => x.GetService <JpProjectAdminUiContext>());
            services.SetupDefaultIdentityServerContext <JpProjectAdminUiContext>();
            return(services);
        }
コード例 #6
0
        public static IJpProjectConfigurationBuilder AddDefaultAspNetIdentityServices(this IJpProjectConfigurationBuilder services)
        {
            // Infra - Identity Services
            services.Services.AddScoped <IUserService, UserService <UserIdentity, RoleIdentity, string> >();
            services.Services.AddScoped <IRoleService, RoleService <RoleIdentity, string> >();
            services.Services.AddScoped <IIdentityFactory <UserIdentity>, IdentityFactory>();
            services.Services.AddScoped <IRoleFactory <RoleIdentity>, IdentityFactory>();

            return(services);
        }
コード例 #7
0
        public static IJpProjectConfigurationBuilder ConfigureIdentity <TUser, TRole, TKey, TRoleFactory, TUserFactory>(this IJpProjectConfigurationBuilder services)
            where TUser : IdentityUser <TKey>, IDomainUser
            where TRole : IdentityRole <TKey>
            where TKey : IEquatable <TKey>
            where TRoleFactory : class, IRoleFactory <TRole>
            where TUserFactory : class, IIdentityFactory <TUser>
        {
            services.Services.AddScoped <IUserService, UserService <TUser, TRole, TKey> >();
            services.Services.AddScoped <IRoleService, RoleService <TRole, TKey> >();
            services.Services.AddScoped <IIdentityFactory <TUser>, TUserFactory>();
            services.Services.AddScoped <IRoleFactory <TRole>, TRoleFactory>();

            return(services);
        }
コード例 #8
0
 public static IJpProjectConfigurationBuilder AddEventStore <TEventStore>(this IJpProjectConfigurationBuilder services)
     where TEventStore : class, IEventStoreContext
 {
     services.Services.AddScoped <IEventStoreContext, TEventStore>();
     return(services);
 }
コード例 #9
0
        public static IJpProjectConfigurationBuilder ConfigureAdminContext <TContext, TEventStore>(this IJpProjectConfigurationBuilder services)
            where TContext : class, IPersistedGrantDbContext, IConfigurationDbContext, IJpEntityFrameworkStore
            where TEventStore : class, IEventStoreContext
        {
            RegisterStorageServices(services.Services);
            services.Services.TryAddScoped <IEventStoreContext>(x => x.GetRequiredService <TEventStore>());
            services.Services.TryAddScoped <IConfigurationDbContext>(x => x.GetRequiredService <TContext>());
            services.Services.TryAddScoped <IPersistedGrantDbContext>(x => x.GetRequiredService <TContext>());
            services.Services.TryAddScoped <IJpEntityFrameworkStore>(x => x.GetRequiredService <TContext>());

            return(services);
        }
コード例 #10
0
 public static IJpProjectConfigurationBuilder ConfigureJpAdminStorageServices(this IJpProjectConfigurationBuilder services)
 {
     RegisterStorageServices(services.Services);
     return(services);
 }