Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
HOW TO BUILDCOMPOSITEAPPLICATIONS WITHPRISMEMIL STOYCHEV, SILVERLIGHT MVP
Bio•   CTO, CompletIT•   Co-founder, SilverlightShow•   Silverlight MVP•   Silverlight Bulgaria UG Lead•   Blog – http://e...
Content• What are Composite Applications?• Design and Technical Concepts in Prism• Quick Starts
What are Composite Applications?    Feature multiple    Rich, flexible user   Role-determined        screens            in...
What are Composite Applications?                                                                               Composite A...
What is Prism?• Set of guidance (not a framework)• Design and build flexible client applications• Will help you if:       ...
Prism Assets• Found at http://prism.codeplex.com• Composite Application Library (CAL) source  code• Stock Trader Reference...
Design Concepts: UI Composition
UI Composition: View Composition• Display views from different modules on  named locations within your app’s UI• View crea...
View Composition: View Injection• Views are programmatically added/ removed  from a named location by the modules
View Composition: View Discovery• Modules register views for a named location
UI Composition: Commanding• Decouple the view from the presentation logic• Move handling logic away from the code  behind
UI Composition: Eventing• Enable communication between components• Event Aggregator – holds event objects
Design Concepts: Modularity• Modularity is designing a system that is  divided into a set of functional units (named  modu...
Design Concepts: Container• Tie modules together using a dependency  injection container• Reduce dependency coupling• Inst...
Design Concepts: Multi-targeting• Write once, use on both WPF and Silverlight• Silverlight and WPF – not binary compatible...
Technical Concepts
Bootstrapper• Responsible for application initialization• CAL includes UnityBootstrapper from Unity
Configure the Container• Register core services  – IModuleInitializer  – IModuleManager  – IRegionManager  – IEventAggrega...
Configuring the RegionAdapter              Mappings• Used by region manager to associate the  correct adapters for XAML-de...
Creating the Shell• Allows greater testability• Shell gets displayed
Initializing the Modules• ModuleManager service is resolved• Creates and loads the ModuleCatalog• Initializes any availabl...
Meet theBOOTSTRAPPER
Module• Module is packaged in an assembly• Must contain an IModule class
Discover Modules• Defining modules in code• Defining modules in XAML• Reading module information from a  configuration fil...
Load Modules• Retrieve module from web (or get from disk)• Transfer into memory
Initialize Modules• Call the module IModule class Initialize  method• Register types with the container• Register views fo...
Module Options• ModuleA can depend on ModuleB• Loading  – WhenAvailable – referenced by the shell  – OnDemand – download f...
DiscoverMODULES
Shell•   Application’s main window•   Contains multiple views•   May contain regions•   May define top UI elements – toolb...
Shell
Regions•   Named locations in a Shell•   Think of a Placeholder•   May contain a single or multiple views•   RegionManager...
View• Collection of UI elements contained in a Shell• Main unit of UI construction• Maight be a UserControl, DataTemplate ...
MeetSHELL, REGIONS, VIEWS
Questions?             35
Thank you!             36
Upcoming SlideShare
Loading in …5
×

Prism

824 views

Published on

by Emil Stoychev (The Silverlight Show) from Bulgaria at my "Pre-MIX!!" ROCK! event

  • Be the first to comment

Prism

  1. 1. HOW TO BUILDCOMPOSITEAPPLICATIONS WITHPRISMEMIL STOYCHEV, SILVERLIGHT MVP
  2. 2. Bio• CTO, CompletIT• Co-founder, SilverlightShow• Silverlight MVP• Silverlight Bulgaria UG Lead• Blog – http://emil.silverlightshow.net• Twitter - @estoychev – do you follow me? 2
  3. 3. Content• What are Composite Applications?• Design and Technical Concepts in Prism• Quick Starts
  4. 4. What are Composite Applications? Feature multiple Rich, flexible user Role-determined screens interaction behavior Built to last and Start small, evolve Quickly response built for change over time to changes Use loosely coupled, independently evolvable pieces
  5. 5. What are Composite Applications? Composite Applications tightly-coupled with no loosely-coupled clear separation of modules Monolithic Applications concerns hard to extend common shell hard to maintain common services hard to test separated hard to deploy presentation patterns easy to introduce new mockability/testability bugs when fixing others
  6. 6. What is Prism?• Set of guidance (not a framework)• Design and build flexible client applications• Will help you if: You must be able to You are developing, Your application will add change the application testing, and deploying more views and more quickly and safely to meet modules independently of functionality over the emergent business the other modules. coming years. requirements. Your application targets Your application is being both WPF and Silverlight, developed by multiple and you want to share as collaborating teams. much code as possible.
  7. 7. Prism Assets• Found at http://prism.codeplex.com• Composite Application Library (CAL) source code• Stock Trader Reference Implementation• Quick Starts• Documentation
  8. 8. Design Concepts: UI Composition
  9. 9. UI Composition: View Composition• Display views from different modules on named locations within your app’s UI• View creation – Programmatically – View Injection – Automatically – View Discovery
  10. 10. View Composition: View Injection• Views are programmatically added/ removed from a named location by the modules
  11. 11. View Composition: View Discovery• Modules register views for a named location
  12. 12. UI Composition: Commanding• Decouple the view from the presentation logic• Move handling logic away from the code behind
  13. 13. UI Composition: Eventing• Enable communication between components• Event Aggregator – holds event objects
  14. 14. Design Concepts: Modularity• Modularity is designing a system that is divided into a set of functional units (named modules) that can be composed into a larger application
  15. 15. Design Concepts: Container• Tie modules together using a dependency injection container• Reduce dependency coupling• Instantiate instances• Manages lifetime – singleton, instance• Usage – register type/instance/service; resolve container.RegisterType<ILogger, DBLogger>(); ILogger logger = container.Resolve<ILogger>();
  16. 16. Design Concepts: Multi-targeting• Write once, use on both WPF and Silverlight• Silverlight and WPF – not binary compatible• The goal is reuse of source code – ViewModels, Models, Controllers, Services, Unit Tests• Harder to reuse – Complex views (xaml), controls, styling, animations
  17. 17. Technical Concepts
  18. 18. Bootstrapper• Responsible for application initialization• CAL includes UnityBootstrapper from Unity
  19. 19. Configure the Container• Register core services – IModuleInitializer – IModuleManager – IRegionManager – IEventAggregator –…
  20. 20. Configuring the RegionAdapter Mappings• Used by region manager to associate the correct adapters for XAML-defined regions• Default mappings – TabControl (Silverlight-only) – Selector – ItemsControl – ContentControl
  21. 21. Creating the Shell• Allows greater testability• Shell gets displayed
  22. 22. Initializing the Modules• ModuleManager service is resolved• Creates and loads the ModuleCatalog• Initializes any available modules
  23. 23. Meet theBOOTSTRAPPER
  24. 24. Module• Module is packaged in an assembly• Must contain an IModule class
  25. 25. Discover Modules• Defining modules in code• Defining modules in XAML• Reading module information from a configuration file• Loading all modules in a directory (only in WPF)
  26. 26. Load Modules• Retrieve module from web (or get from disk)• Transfer into memory
  27. 27. Initialize Modules• Call the module IModule class Initialize method• Register types with the container• Register views for a region• Integrate with application – Subscribe to events – Add view to app navigation
  28. 28. Module Options• ModuleA can depend on ModuleB• Loading – WhenAvailable – referenced by the shell – OnDemand – download from Web when needed
  29. 29. DiscoverMODULES
  30. 30. Shell• Application’s main window• Contains multiple views• May contain regions• May define top UI elements – toolbar, menu
  31. 31. Shell
  32. 32. Regions• Named locations in a Shell• Think of a Placeholder• May contain a single or multiple views• RegionManager – Holds regions – Creates regions• RegionContext – Share context between parent and child view
  33. 33. View• Collection of UI elements contained in a Shell• Main unit of UI construction• Maight be a UserControl, DataTemplate or a Custom Control• Composite Views – contain a view in itself – most commonly by defining a region
  34. 34. MeetSHELL, REGIONS, VIEWS
  35. 35. Questions? 35
  36. 36. Thank you! 36

×