模塊 = 後臺邏輯(DLL)+ 顯示邏輯(靜態資源)+ 數據庫 + 其它初始化邏輯。數據庫
1 [assembly: Happy.Bootstrap.ParticipateInBootstrap]
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using System.IO; 7 8 using Happy.Bootstrap; 9 10 namespace Happy.Example 11 { 12 public sealed class BootstrapListener : IBootstrapListener 13 { 14 public void Start(IBootstrapService bootstrapService) 15 { 16 File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log.txt"), "模塊已經啓動"); 17 } 18 } 19 }
這個是後話,先不介紹了。bootstrap
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.Http; 6 using System.Web.Mvc; 7 using System.Web.Routing; 8 using System.Threading; 9 10 using Happy.Bootstrap; 11 using Happy.Web.Bootstrap; 12 using Happy.Event.Bootstrap; 13 using Happy.Domain.Bootstrap; 14 using Happy.Command.Bootstrap; 15 using Happy.Application.Bootstrap; 16 using Happy.Application; 17 using Happy.Application.PessimisticLock; 18 19 namespace Happy.Web.Mvc.Host 20 { 21 // Note: For instructions on enabling IIS6 or IIS7 classic mode, 22 // visit http://go.microsoft.com/?LinkId=9394801 23 public class MvcApplication : System.Web.HttpApplication 24 { 25 protected void Application_Start() 26 { 27 BootstrapService 28 .Current 29 .UseRegisterServiceByConventionPlug() 30 .UseEventSubscriberRegister() 31 .UseDomainLayerRegister(ServiceLifecycle.PerRequest) 32 .UseCommandRegister() 33 .UseApplicationLayerRegister() 34 .Done() 35 .IntegrateWithMvc() 36 .IntegrateWithExtJs() 37 .Start(); 38 39 AreaRegistration.RegisterAllAreas(); 40 41 WebApiConfig.Register(GlobalConfiguration.Configuration); 42 FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 43 RouteConfig.RegisterRoutes(RouteTable.Routes); 44 } 45 } 46 }
模塊化開發會遇到不少問題,不過有些問題能夠做爲一個限制,好比能夠這樣限制一下:1、同一個組件只容許一個版本;2、全部DLL都部署到bin中,不然你本身加載DLL和重寫ControllerFactory。app