/// <summary> /// 使用Web。 /// </summary> /// <param name="kernelBuilder">内核建设者。</param> /// <param name="webBuilder">Web建设动作。</param> /// <param name="routes">路由集合,如果为 null 则默认为 RouteTable.Routes。</param> public static void UseWeb(this IKernelBuilder kernelBuilder, Action <IWebBuilder> webBuilder, RouteCollection routes = null) { kernelBuilder .RegisterExtension(typeof(BuilderExtensions).Assembly) .OnStarting(builder => { builder.RegisterInstance(routes ?? RouteTable.Routes); builder.RegisterType <WebHost>().As <IWebHost>().As <IHost>().As <IEventHandler>() /*.Named<IEventHandler>(typeof(IShellSettingsManagerEventHandler).Name) * .Named<IEventHandler>(typeof(IShellDescriptorManagerEventHandler).Name)*/ .As <IShellSettingsManagerEventHandler>() .As <IShellDescriptorManagerEventHandler>() .SingleInstance(); builder.RegisterModule <WebModule>(); builder.RegisterType <DefaultRunningShellTable>().As <IRunningShellTable>().SingleInstance(); }); if (webBuilder != null) { webBuilder(new WebBuilder(kernelBuilder)); } }
/// <summary> /// 使用命令行。 /// </summary> /// <param name="kernelBuilder">内核建设者。</param> public static void UseCommand(this IKernelBuilder kernelBuilder) { kernelBuilder .RegisterExtension(typeof(BuilderExtensions).Assembly) .OnStarting(builder => builder.RegisterType <MinimumShellDescriptorProvider>() .As <IMinimumShellDescriptorProvider>() .SingleInstance()); }
public static void UseInfrastructures(this IKernelBuilder kernelBuilder) { kernelBuilder.RegisterExtension(typeof(BuilderExtensions).Assembly); }