예제 #1
0
        public static IEnumerable <SmartServiceDescriptor> GetServices(SchubertWebOptions options, bool append = true)
        {
            Guard.ArgumentNotNull(options, nameof(options));

            if (append)
            {
                yield return(ServiceDescriber.Transient <IModuleFinder, PackageFinder>(SmartOptions.Append));

                yield return(ServiceDescriber.Singleton <IWorkContextProvider, HttpWorkContextProvider>(SmartOptions.Append));

                yield return(ServiceDescriber.Transient <IShellBlueprintItemExporter, ControllerExporter>(SmartOptions.Append));
            }

            yield return(ServiceDescriber.Singleton <IHttpContextAccessor, HttpContextAccessor>());

            yield return(ServiceDescriber.Scoped <HttpWorkContext, HttpWorkContext>());

            yield return(ServiceDescriber.Transient <ISchubertEnvironment, AspNetEnvironment>());

            yield return(ServiceDescriber.Transient <ICookiesAccessor, CookiesAccessor>());

            yield return(ServiceDescriber.Scoped <IClientEnvironment, ClientEnvironment>());


            if (options.MvcFeatures != MvcFeatures.None)
            {
                yield return(ServiceDescriber.Transient <IApplicationModelProvider, SchubertApplicationModeProvider>(SmartOptions.TryAppend));

                if (options.MvcFeatures == MvcFeatures.Full)
                {
                    yield return(ServiceDescriber.Scoped <IHtmlSegmentManager, HtmlSegmentManager>());
                }
            }
        }
예제 #2
0
        public static IEnumerable <SmartServiceDescriptor> GetServices(DbOptions options)
        {
            Guard.ArgumentNotNull(options, nameof(options));

            yield return(ServiceDescriber.Scoped(typeof(IRepository <>), typeof(Repository <>)));

            yield return(ServiceDescriber.Scoped(typeof(IRepository <,>), typeof(Repository <,>)));

            yield return(ServiceDescriber.Scoped(typeof(IMigrationsAssembly), typeof(MigrationFinder), SmartOptions.Replace));

            yield return(ServiceDescriber.Singleton(typeof(IModelCustomizer), typeof(SchubertModelCustomizer), SmartOptions.Append));

            yield return(ServiceDescriber.Singleton(typeof(ICoreConventionSetBuilder), typeof(SchubertConventionSetBuilder), SmartOptions.Append));

            yield return(ServiceDescriber.Scoped <ILanguageService, LanguageService>());
        }
예제 #3
0
        public static IEnumerable <SmartServiceDescriptor> GetServices(DapperDatabaseOptions options)
        {
            Guard.ArgumentNotNull(options, nameof(options));

            yield return(ServiceDescriber.Scoped <DapperContext, DapperContext> ());

            yield return(ServiceDescriber.Scoped <IDatabaseContext>(s => s.GetRequiredService <DapperContext>()));

            yield return(ServiceDescriber.Singleton <DapperRuntime, DapperRuntime>());

            //yield return ServiceDescriber.Scoped<IRepository<ShellDescriptorRecord>, Repository<ShellDescriptorRecord, ShellDescriptorDbContext>>();
            //yield return ServiceDescriber.Scoped<IRepository<SettingRecord>, Repository<SettingRecord, ShellDescriptorDbContext>>();
            yield return(ServiceDescriber.Scoped(typeof(IRepository <>), typeof(DapperRepository <>)));

            //yield return ServiceDescriber.Transient<IShellDescriptorManager, ShellDescriptorManager>();
            //yield return ServiceDescriber.Scoped<ILanguageService, LanguageService>();
        }
예제 #4
0
        /// <summary>
        /// 获取框架中的基础服务。
        /// </summary>
        public static IEnumerable <SmartServiceDescriptor> GetServices(IConfiguration configuration)
        {
            //基础运行环境。

            yield return(ServiceDescriber.Singleton(typeof(IOptions <>), typeof(OptionsManager <>)));

            yield return(ServiceDescriber.Singleton <IInstanceIdProvider, DefaultInstanceIdProvider>());

            string configValue = configuration["Schubert:Env"];

            yield return(ServiceDescriber.Transient <ISchubertEnvironment>(s =>
                                                                           new DefaultRuntimeEnvironment(configValue ?? "Production", s.GetRequiredService <IInstanceIdProvider>())));

            //系统内置服务
            yield return(ServiceDescriber.Singleton <ICacheManager, MemoryCacheManager>());

            //事件通知
            yield return(ServiceDescriber.Singleton <IEventNotification, EventNotification>());

            //文件系统
            yield return(ServiceDescriber.Singleton <IFileStorageManager, FileStorageManager>());

            yield return(ServiceDescriber.Transient <IAppDataFolderRoot, AppDataFolderRoot>());

            yield return(ServiceDescriber.Transient <IAppDataFolder, AppDataFolder>());

            //运行环境基础服务
            yield return(ServiceDescriber.Singleton <IIdGenerationService, SnowflakeIdGenerationService>());

            yield return(ServiceDescriber.Transient <IShellDescriptorManager, NullShellDescriptorManager>());

            yield return(ServiceDescriber.Transient <IAssemblyReader, DefaultAssemblyReader>());

            yield return(ServiceDescriber.Transient <IPathProvider, DefaultPathProvider>());

            yield return(ServiceDescriber.Singleton <IWorkContextAccessor, DefaultWorkContextAccessor>());

            yield return(ServiceDescriber.Scoped <WorkContext>(sp => sp.GetRequiredService <IWorkContextAccessor>().GetContext()));

            yield return(ServiceDescriber.Scoped <IWorkContextStateProvider, UserStateProvider>(SmartOptions.Append));

            yield return(ServiceDescriber.Scoped <IWorkContextStateProvider, LanguageStateProvider>(SmartOptions.Append));

            yield return(ServiceDescriber.Scoped <IWorkContextStateProvider, TimeZoneStateProvider>(SmartOptions.Append));

            yield return(ServiceDescriber.Scoped <IWorkContextStateProvider, TransactionStateProvider>(SmartOptions.Append));

            //模块化功能
            yield return(ServiceDescriber.Transient <IModuleHarvester, XmlHarvester>(SmartOptions.Append)); // IModuleHarvester 可以存在多个实例

            yield return(ServiceDescriber.Transient <IModuleHarvester, JsonHarvester>(SmartOptions.Append));

            yield return(ServiceDescriber.Transient <IModuleFinder, EntryPointFinder>(SmartOptions.Append));

            yield return(ServiceDescriber.Transient <IModuleFinder, RunningFolderFinder>(SmartOptions.Append));

            yield return(ServiceDescriber.Transient <IModuleLoader, ClrModuleLoader>(SmartOptions.Append));  //该服务可以存在多个实例

            yield return(ServiceDescriber.Transient <IShellDescriptorCache, NullShellDescriptorCache>());

            yield return(ServiceDescriber.Transient <IModuleManager, ModuleManager>());

            yield return(ServiceDescriber.Transient <IFeatureManager, FeatureManager>());

            yield return(ServiceDescriber.Transient <IShellBlueprintItemExporter, DependencyDescriberExporter>(SmartOptions.Append));

            yield return(ServiceDescriber.Transient <IShellBlueprintItemExporter, DependencyExporter>(SmartOptions.Append));

            yield return(ServiceDescriber.Transient <IShellBlueprintItemExporter, OptionsExporter>(SmartOptions.Append));

            yield return(ServiceDescriber.Singleton <IInstanceIdProvider, DefaultInstanceIdProvider>());

            yield return(ServiceDescriber.Singleton <IInstanceIdProvider, DefaultInstanceIdProvider>());

            //Shell 服务
            yield return(ServiceDescriber.Transient <ICompositionStrategy, CompositionStrategy>());

            yield return(ServiceDescriber.Transient <IShellContextFactory, ShellContextFactory>());

            //全球化
            yield return(ServiceDescriber.Singleton <ILocalizedStringManager, LocalizedStringManager>());

            yield return(ServiceDescriber.Scoped <IPermissionService, NullPermissionService>());

            yield return(ServiceDescriber.Scoped <ILanguageService, NullLanguageService>());

            yield return(ServiceDescriber.Scoped <IIdentityService, NullIdentityService>());

            yield return(ServiceDescriber.Singleton <IDistributedOptimisticStoreService, DebugOnlyFileStoreService>());


            //日志
            yield return(ServiceDescriber.Scoped <ILogService, NullLogService>());
        }