/// <summary> /// 将OSharp服务添加到容器 /// </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); } OSharpModuleManager manager = new OSharpModuleManager(builder, new AppDomainAllAssemblyFinder()); manager.LoadModules(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); }
/// <summary> /// OSharp框架初始化 /// </summary> public static IApplicationBuilder UseOSharpMvc(this IApplicationBuilder app) { IServiceProvider serviceProvider = app.ApplicationServices; OSharpModuleManager moduleManager = serviceProvider.GetService <OSharpModuleManager>(); moduleManager.UseModules(serviceProvider); return(app); }