Exemplo n.º 1
0
        /// <summary>
        /// 将OSharp服务,各个<see cref="OsharpPack"/>模块的服务添加到服务容器中
        /// </summary>
        public static IServiceCollection AddOSharp(this IServiceCollection services, Action <IOSharpBuilder> builderAction = null, AppServiceScanOptions scanOptions = null)
        {
            Check.NotNull(services, nameof(services));

            IOSharpBuilder builder = new OSharpBuilder();

            if (builderAction != null)
            {
                builderAction(builder);
            }
            OSharpPackManager manager = new OSharpPackManager(builder, new AppDomainAllAssemblyFinder());

            manager.LoadPacks(services);
            services.AddSingleton(provider => manager);
            if (scanOptions == null)
            {
                scanOptions = new AppServiceScanOptions();
            }
            services = new AppServiceAdder(scanOptions).AddServices(services);
            if (builder.OptionsAction != null)
            {
                services.Configure(builder.OptionsAction);
            }
            return(services);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 将OSharp服务,各个<see cref="OsharpPack"/>模块的服务添加到服务容器中
        /// </summary>
        public static IServiceCollection AddOSharp(this IServiceCollection services, Action <IOSharpBuilder> builderAction = null)
        {
            Check.NotNull(services, nameof(services));

            IOSharpBuilder builder = new OSharpBuilder();

            if (builderAction != null)
            {
                builderAction(builder);
            }
            OSharpPackManager manager = new OSharpPackManager(builder, new AppDomainAllAssemblyFinder());

            manager.LoadPacks(services);
            services.AddSingleton(provider => manager);
            return(services);
        }