コード例 #1
0
        public static IAppServiceCollectionBuilder AddDependency(this IAppServiceCollectionBuilder builder)
        {
            builder.Services.Scan(scan =>
            {
                scan.FromAssemblies(AssemblyLoader.GetAssemblies())
                .AddClasses(c => c.Where(t => typeof(ITransientDependency).IsAssignableFrom(t) && t != typeof(ITransientDependency) && !t.IsAbstract))
                .AsImplementedInterfaces()
                .WithTransientLifetime();


                scan.FromAssemblies(AssemblyLoader.GetAssemblies())
                .AddClasses(c => c.Where(t => typeof(ISingletonDependency).IsAssignableFrom(t) && t != typeof(ISingletonDependency) && !t.IsAbstract))
                .AsImplementedInterfaces()
                .WithSingletonLifetime();


                scan.FromAssemblies(AssemblyLoader.GetAssemblies())
                .AddClasses(c => c.Where(t => typeof(IApplicationService).IsAssignableFrom(t) && t != typeof(IApplicationService) && !t.IsAbstract))
                .AsImplementedInterfaces()
                .WithTransientLifetime();


                scan.FromAssemblies(AssemblyLoader.GetAssemblies())
                .AddClasses(c => c.AssignableTo(typeof(IRepository)))
                .AsImplementedInterfaces()
                .WithTransientLifetime();
            });
            return(builder);
        }
コード例 #2
0
        public static IAppServiceCollectionBuilder AddEntityFrameWork(this IAppServiceCollectionBuilder builder)
        {
            builder.Services.AddSingleton <IEntityFrameworkConfiguration, EntityFrameworkConfiguration>();
            builder.Services.AddTransient <IUnitOfWork, EntityFrameworkUnitOfWork>();
            builder.Services.AddTransient(typeof(IEntityFrameworkDbContextProvider <>), typeof(EntityFrameworkDbContextProvider <>));

            return(builder);
        }
コード例 #3
0
        public static IAppServiceCollectionBuilder AddAutoMapper(this IAppServiceCollectionBuilder builder, Action <IAutoMapperConfiguration> invoke = null)
        {
            builder.Services.AddSingleton <IAutoMapperConfiguration>(provider =>
            {
                var c = new AutoMapperConfiguration();
                invoke?.Invoke(c);
                return(c);
            });

            return(builder);
        }
コード例 #4
0
        public static IAppServiceCollectionBuilder AddUnitOfWork(this IAppServiceCollectionBuilder builder, Action <IUnitOfWorkConfiguration> invoke = null)
        {
            builder.Services.AddSingleton <IUnitOfWorkConfiguration>(provider =>
            {
                var c = new UnitOfWorkConfiguration();
                invoke?.Invoke(c);
                return(c);
            });

            builder.Services.AddTransient <IUnitOfWorkProvider, UnitOfWorkProvider>();
            builder.Services.AddTransient <IUnitOfWorkManager, UnitOfWorkManager>();

            return(builder);
        }
コード例 #5
0
        public static IAppServiceCollectionBuilder AddGlobalSettingManager(this IAppServiceCollectionBuilder builder, Action <IGlobalSettingConfiguration> invoke = null)
        {
            builder.Services.AddSingleton <IGlobalSettingConfiguration>(provider =>
            {
                var c = new GlobalSettingConfiguration();
                invoke?.Invoke(c);
                return(c);
            });
            builder.Services.AddTransient <IGlobalSettingStore, GlobalSettingConfigurationStore>();
            builder.Services.AddSingleton <IGlobalSettingManager, GlobalSettingManager>();

            builder.Services.Scan(scan =>
            {
                scan.FromAssemblies(AssemblyLoader.GetAssemblies())
                .AddClasses(c => c.AssignableTo(typeof(GlobalSettingProvider)))
                .AsSelf()
                .WithSingletonLifetime();
            });

            return(builder);
        }
コード例 #6
0
        public static IAppServiceCollectionBuilder AddCacheManager(this IAppServiceCollectionBuilder builder, Action <ICacheSettingsConfiguration> invoke = null)
        {
            builder.Services.AddSingleton <ICacheSettingsConfiguration>(provider =>
            {
                var c = new CacheSettingsConfiguration();
                invoke?.Invoke(c);
                return(c);
            });

            builder.Services.AddSingleton <ICacheSettingManager, CacheSettingManager>();
            builder.Services.AddSingleton <ICacheSettingsConfiguration, CacheSettingsConfiguration>();
            builder.Services.AddSingleton <ICacheManager, MemoryCacheManager>();

            builder.Services.Scan(scan =>
            {
                scan.FromAssemblies(AssemblyLoader.GetAssemblies())
                .AddClasses(c => c.AssignableTo(typeof(CacheSettingProvider)))
                .AsSelf()
                .WithSingletonLifetime();
            });

            return(builder);
        }
コード例 #7
0
 public static IAppServiceCollectionBuilder AddLoggerInterception(this IAppServiceCollectionBuilder builder)
 {
     builder.Services.AddInterception();
     return(builder);
 }
コード例 #8
0
 public static IAppServiceCollectionBuilder AddClaimsUserSession(this IAppServiceCollectionBuilder builder)
 {
     builder.Services.AddTransient <IUserSession, ClaimsUserSession>();
     return(builder);
 }