Presentation is loading. Please wait.

Presentation is loading. Please wait.

Overview of the Composite Application Guidance for WPF Adam Calderon Application Development Practice Lead.

Similar presentations


Presentation on theme: "Overview of the Composite Application Guidance for WPF Adam Calderon Application Development Practice Lead."— Presentation transcript:

1

2 Overview of the Composite Application Guidance for WPF Adam Calderon Application Development Practice Lead

3 Contact Information More info on InterKnowlogy: www.InterKnowlogy.com Contact Information E-mail: adamc@InterKnowlogy.com Phone: 760-930-0075 x274 Blog: http://blogs.InterKnowlogy.com/AdamCalderon About Adam Calderon Microsoft MVP – C# Microsoft UI Server Frameworks Advisory Council Developer / Author / Speaker / Teacher

4 Agenda What you can produce with CAL Key concepts of a CAL application How you can find out more?

5 Demo Stock Trader Reference Implementation

6 Core Concepts Bootstrapper Modules Services and Containers Regions Views Events and Commands

7 Demo Look Inside Stock Trader Reference Implementation Solution

8 Modules Provide a way to isolate functionality that can be used in many areas Enhances team development Common Usages Specific application feature such as news Specific subsystem such as purchasing, invoicing, and general ledger Infrastructure services such as logging and authorization services or Web services

9 Static Module Loading public class MyBootstrapper : UnityBootstrapper {... protected override IModuleEnumerator GetModuleEnumerator() { return new StaticModuleEnumerator().AddModule(typeof(SomeModule)).AddModule(typeof(AnotherModule), "SomeModule").AddModule(typeof(YetAnotherModule), "AnotherModule","SomeModule"); } Module Dependencies Module type Locates modules Returns statically referenced modules

10 public class SomeModule : IModule public SomeModule(SomeDependency myDependency) {...} public void Initialize() { RegisterViewsAndServices(); //Show views here; } Module Initialization Dependency injected Initialization logic "Have it your way"

11 Demo Breaking up an application with Static Modules

12 Dynamic Module Loading public class MyBootstrapper : UnityBootstrapper {... protected override IModuleEnumerator GetModuleEnumerator() { return new StaticModuleEnumerator().AddModule(typeof(SomeModule)).AddModule(typeof(AnotherModule), new[] {"SomeModule“}).AddModule(typeof(YetAnotherModule), new[] { "AnotherModule" }) } public class MyBootstrapper : UnityBootstrapper {... protected override IModuleEnumerator GetModuleEnumerator() { return new DirectoryLookupModuleEnumerator(@".\Modules"); } Scans folders for modules

13 Regions and Views Regions contain content that is dynamically added Modules insert content into regions Views can consist of User Controls or data that contains an associated data template

14 Region Mappings

15 Region Registration MyShell.xaml RegionName attached property Most Regions are ItemsControls Most Regions are ItemsControls <TabControl x:Name="OrderTab" ItemContainerStyle="..." cal:RegionManager.RegionName="OrderRegion" />

16 Views as User Controls public class MyModule : IModule { public void Initialize (IRegionManager manager) { RegisterViewsAndServices(); IRegion orderRegion = manager.GetRegion("OrderRegion"); var myOrderView = new OrderView(myOrder); orderRegion.Add(myOrderView); } Region manager is needed View is created Region is retrieved View is shown

17 Views Represented by Templates public class MyModule : IModule { public void Initialize(IRegionManager manager) { RegisterViewsAndServices(); IRegion orderRegion = manager.GetRegion("OrderRegion"); orderRegion.Add(myOrder); } Order is added directly

18 Demo Taking a look at Regions

19 Commands Routed Commands can introduce issues in composite applications Delegate Commands don’t bubble up through element tree Composite Commands provide a mechanism to call 1..n Delegate Commands

20 Composition Commands SubmitSubmit OrderDetails SubmitSubmit SubmitSubmit Submit All Delegate Commands Composite Command

21 Building a Composite Command <Button Name="SubmitAllToolbarButton" Command="{x:Static inf:Commands.SubmitOrdersCommand}"> Submit All </StackPanel Wire up the Command

22 Registering a Child Command Connecting the child to the parent public class OrderDetailsPresenter : IOrderDetailsPresenter { private ICommand orderSubmitCommand; public OrderDetailsPresenter(...) { orderSubmitCommand = … // Register the command Commands.SubmitOrdersCommand.RegisterCommand(orderSubmitCommand); }

23 Handling the Command public class OrderDetailsPresenter : IOrderDetailsPresenter { private ICommand orderSubmitCommand; public OrderDetailsPresenter (IOrderDetailsView view, { orderSubmitCommand = new DelegateCommand(Submit, CanSubmit); // Register the command Commands.SubmitOrdersCommand.RegisterCommand(orderSubmitCommand); } public void Submit(object params) {...} public bool CanSubmit(object params) {...} } Handling the canExecute and Execute

24 Demo Taking a look at Commands

25 Events Event Aggregation allows for decoupling of events Provides a mechanism that allows newly added modules to subscribe to events from other parts of application Implemented as a service

26 Event Aggregation EventAggregatorServiceEventAggregatorService OrderReceivedOrderReceived OrderManagerOrderManager OrderListPresenterOrderListPresenter SubscribesSubscribes OrderModuleOrderModule OrderServiceOrderService PublishesPublishes ReceivesReceives

27 Event Aggregation – The Event public class OrderReceivedEvent : CompositeWPFEvent { ….. } Decouples publisher and subscriber

28 Event Aggregation-Subscription public class SomePresenter { public SomePresenter (IEventAggregator eventAggregator) { //subscribing to the event eventAggregator.Get (). Subscribe(OnOrderReceived, ThreadOption.UIThread); } private void OnOrderReceived(Order order) {... } Repository for events Retrieving the event Subscribing to the event Dispatching to the correct thread

29 Event Aggregation-Subscription 2 public class SomePresenter { public SomePresenter (IEventAggregator eventAggregator) { //subscribing to the event eventAggregator.Get (). Subscribe(OnOrderReceived, ThreadOption.UIThread, false, o=>o.Priority == Priority.High); ); } private void OnOrderReceived(Order order) {... } Keep the subscriber alive Subscription filter Predicate Subscription filter Predicate

30 Event Aggregation-Publish public class OrderService : IOrderService { public OrderService(IEventAggregator eventAggregator) {...} private void OrderReceived(Order) { //publish EventAggregator.Get (). Publish(Order); } Publish the event

31 Demo Taking a look at Events

32 What is going to be shipped Stock Trader RI Libraries Documentation How-Tos Quickstarts

33 Capabilities and Features Region Manager Region Attached Properties MVP / Presentation Model Regions and Views Static Directory Sweep Configuration Driven On-Demand Module Loading Event Aggregator Composite Command Delegate Command Active Aware Composite Command Active Aware Delegate Command Communication

34 Where can you find it http://www.codeplex.com/CompositeWPF

35 Contact Information More info on InterKnowlogy: www.InterKnowlogy.com Contact Information E-mail: adamc@InterKnowlogy.com Phone: 760-930-0075 x274 Blog: http://blogs.InterKnowlogy.com/AdamCalderon About Adam Calderon Microsoft MVP – C# Microsoft UI Server Frameworks Advisory Council Developer / Author / Speaker / Teacher


Download ppt "Overview of the Composite Application Guidance for WPF Adam Calderon Application Development Practice Lead."

Similar presentations


Ads by Google