예제 #1
0
        public static IServiceCollection AddModules <TModule>(this IServiceCollection services,
                                                              Action <ModuleRegisterBuilder <TModule> > registerModules)
            where TModule : class, IModule
        {
            var registerModulesBuilder = new ModuleRegisterBuilder <TModule>(services);

            registerModules(registerModulesBuilder);
            return(services);
        }
예제 #2
0
        public static IServiceCollection AddMvcModules <TModule>(this IServiceCollection servicies,
                                                                 Action <ModuleRegisterBuilder <TModule> > registerModules)
            where TModule : class, IModule
        {
            var routeHandler           = DefaultRouteHandler ?? sp.GetRequiredService <MvcRouteHandler>();
            var registerModulesBuilder = new ModuleRegisterBuilder <TModule>(servicies, defaultRouteHandler);

            registerModules(registerModulesBuilder);
            return(servicies);
        }
 public MvcModulesBuilder(ModuleRegisterBuilder <TModule> parentBuilder, Action <Microsoft.AspNetCore.Mvc.MvcOptions> mvcOptionsSetup = null)
 {
     ParentBuilder = parentBuilder;
     if (mvcOptionsSetup != null)
     {
         parentBuilder.Services.AddMvc(mvcOptionsSetup);
     }
     else
     {
         parentBuilder.Services.AddMvc();
     }
     //  DefaultRouteHandler = new MvcRouteHandler
 }
예제 #4
0
        public static ModuleRegisterBuilder <TModule> ConfigureMvc <TModule>(this ModuleRegisterBuilder <TModule> builder, Action <MvcOptions> mvcOptionsSetup = null)
            where TModule : class, IRoutedModule
        {
            if (mvcOptionsSetup != null)
            {
                builder.Services.AddMvc(mvcOptionsSetup);
            }
            else
            {
                builder.Services.AddMvc();
            }

            var routeHandler = sp.GetRequiredService <MvcRouteHandler>();

            return(builder);
        }