• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Prism
 

Prism

on

  • 536 views

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

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

Statistics

Views

Total Views
536
Views on SlideShare
536
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • To compose your user interface, you need an architecture that allows you to create a layout composed of loosely coupled visual elements at run time and that provides strategies for these visual elements to communicate in a loosely coupled fashion.
  • application contains a registry of named locations in the UI and a module can look up one of the locations using the registry and then programmatically inject views into it.
  • When that location is displayed at run time, any views that have been registered for that location will be automatically created and displayed within it.
  • Enable testability
  • Applications based on the Composite Application Library are composites that potentially consist of many loosely coupled modules. They need to interact with the shell to contribute content and receive notifications based on user actions. Because they are loosely coupled, they need a way to interact and communicate with one another to deliver the required business functionality.
  • The bootstrapper is responsible for the initialization of an application built using the Composite Application Library. By using a bootstrapper, you have more control of how the Composite Application Library components are wired up to your application.
  • During this phase, the shell will be displayed if it exists. Having the creation of the shell in the bootstrapper allows greater testability of the application because the shell can be mocked in a unit test.
  • During this phase, module loading occurs. First, the module manager service is resolved from the container. After that, the Run method of the module manager service is invoked. This method validates the module catalog and initializes the available modules.
  • The ModuleCatalog holds information about the modules that can be used by the application. Each module is described in a ModuleInfo class that records the name, type, and location, among other attributes of the module.
  • After the ModuleCatalog is populated, the modules are ready to be loaded and initialized. Module loading means that the module assembly is transferred from disk into memory. If the assembly is not present on disk, it might have to be retrieved first. An example of this is downloading assemblies from the Web using Silverlight XAP files. The ModuleManager is responsible for coordinating the whole loading and initialization process.
  • Finally, the modules have to be initialized. This means, an instance of the module classes must be created and their Initialize() method must be called

Prism Prism Presentation Transcript

  • HOW TO BUILDCOMPOSITEAPPLICATIONS WITHPRISMEMIL STOYCHEV, SILVERLIGHT MVP
  • Bio• CTO, CompletIT• Co-founder, SilverlightShow• Silverlight MVP• Silverlight Bulgaria UG Lead• Blog – http://emil.silverlightshow.net• Twitter - @estoychev – do you follow me? 2
  • 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 interaction behavior Built to last and Start small, evolve Quickly response built for change over time to changes Use loosely coupled, independently evolvable pieces
  • 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
  • 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.
  • Prism Assets• Found at http://prism.codeplex.com• Composite Application Library (CAL) source code• Stock Trader Reference Implementation• Quick Starts• Documentation
  • Design Concepts: UI Composition
  • 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
  • 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 modules) that can be composed into a larger application
  • 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>();
  • 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
  • Technical Concepts
  • Bootstrapper• Responsible for application initialization• CAL includes UnityBootstrapper from Unity
  • Configure the Container• Register core services – IModuleInitializer – IModuleManager – IRegionManager – IEventAggregator –…
  • 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
  • Creating the Shell• Allows greater testability• Shell gets displayed
  • Initializing the Modules• ModuleManager service is resolved• Creates and loads the ModuleCatalog• Initializes any available modules
  • 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 file• Loading all modules in a directory (only in WPF)
  • 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 for a region• Integrate with application – Subscribe to events – Add view to app navigation
  • Module Options• ModuleA can depend on ModuleB• Loading – WhenAvailable – referenced by the shell – OnDemand – download from Web when needed
  • DiscoverMODULES
  • Shell• Application’s main window• Contains multiple views• May contain regions• May define top UI elements – toolbar, menu
  • Shell
  • 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
  • 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
  • MeetSHELL, REGIONS, VIEWS
  • Questions? 35
  • Thank you! 36