/// <summary>
        /// 应用OSharp框架,初始化各个Pack
        /// </summary>
        public static IServiceProvider UseOSharp(this IServiceProvider provider)
        {
            OSharpPackManager packManager = provider.GetService <OSharpPackManager>();

            packManager.UsePacks(provider);
            return(provider);
        }
Beispiel #2
0
        /// <summary>
        /// OSharp框架初始化
        /// </summary>
        public static IApplicationBuilder UseOSharp(this IApplicationBuilder app)
        {
            IServiceProvider  provider    = app.ApplicationServices;
            OSharpPackManager packManager = provider.GetService <OSharpPackManager>();

            packManager.UsePacks(app);

            return(app);
        }
Beispiel #3
0
        public static IServiceProvider UnitTestInit(this IServiceCollection services)
        {
            services.AddOSharp(build => build.AddCorePack());
            IServiceProvider  provider    = services.BuildServiceProvider();
            OSharpPackManager packManager = provider.GetService <OSharpPackManager>();

            packManager.UsePacks(provider);
            return(provider);
        }
Beispiel #4
0
        public void TrySetApplicationServiceProvider_Test()
        {
            IServiceCollection services = new ServiceCollection();

            services.AddScoped <ServiceLocatorTests, ServiceLocatorTests>();
            services.AddLogging();
            services.AddOSharp(b => b.AddCorePack());

            IServiceProvider  provider    = services.BuildServiceProvider();
            OSharpPackManager packManager = provider.GetService <OSharpPackManager>();

            packManager.UsePacks(provider);

            ServiceLocator.Instance.GetService <ServiceLocatorTests>().ShouldNotBeNull();
        }