工厂方法之IoC
2020-10-20 20:54:26 0 举报
工厂方法模式实现MvcEngine框架
作者其他创作
大纲/内容
SingletonControllerActivator
+ CreateControllerAsync(HttpContext httpContaxt)+ ReleaseAsync(Controller controller)
DefaultControllerExecutor
DefaultControllerActivator
+ CreateControllerAsync(HttpContext httpContext)+ ReleaseAsync(Controller controller)
DefaultWebListener
+ ListenAsync(Uri address)+ ReceiveAsync()
<<interface>>IWebListener
<<interface>>IControllerExecutor
MvcEngine
- listener:IWebListener = GetWebListener()- activator:IControllerActivator=GetControllerActivator()- executor:IControllerExecutor=GetControllerExecutor()- renderer:IViewRender=GetViewRenderer()
+ StartAsync(Uri address)# GetWebListener():IWebListener=>new DefaultWebListener()# GetControllerActivator():IControllerActivator=>new DefaultControllerActivator()# GetControllerExecutor():IControllerExecutor=>new DefaultControllerExecutor()# GetViewRenderer():IViewRender=>new DefaultViewRenderer()
DefaultViewRender
<<interface>>IViewRender
FoobarMvcEngine
# GetControllerActivator():IControllerActivator=>new SingletonControllerActivator()
优势显现,可以对默认框架中的任何步骤进行定制
控制反转,构建默认框架
<<interface>>IControllerActivator
0 条评论
下一页