【正文】
} Demo CAB 設(shè)計中所采用的幾種模式 Implement pattern… By… Model View Controller Using the controller attribute on the view to get injection Using the controller base class on your controllers Saving model objects in WorkItem state Application Controller Encapsulate into the WorkItem the logic to open, traverse, and close views, executing logic in between, Keep views independent of each other Blackboard Using the WorkItem state as the blackboard Components in the WorkItem can access it and collaborate on it independently Memento Have controllers place the state that might need to be managed externally or persisted into WorkItem state WorkItem state can be saved amp。 } public class ControllerX : Component ( private Customer cust。 ApplicationHost Default Work Item Child Work Item 1 Child WorkItem 2 Service1 Service2 Component1 Component2 Component3 Component4 Component5 Service3 添加和定位服務(wù) 使用 Service Locator 和 Injection 模式 Adding Services CAB Foundation Services Moduleadded services Programmatically Declaratively Acquiring Services Find in upstream containers Programmatically Declaratively ApplicationHost A Work Item Module Loader Module [Service(typeof(IMyService))] public class MyService : IMyService { } IMyService MyService View Controller public class MyComponent { [ServiceDependency] IMyService myService。 Base Classes Hosted Control Layout MDI StatusStrip UI Element MenuStrip UI Element ToolStrip UI Element Services CatalogReader Loader Authentication [Logging?] Module 1 SmartPart 1 Controller 1 Shared State Module 2 Shared State SmartPart X Controller X SmartPart Y Controller Y Main Form Initializer [Authorization?] Biz Logic 開發(fā) Infrastructure 開發(fā) Shell 開發(fā) A Work Item 設(shè)計組合型應(yīng)用 – 應(yīng)用邏輯 將 views ( SmartPart)設(shè)計為獨立于 controllers 的單元