Introduction to Microsoft Prism
-
Upload
tomas-maconko -
Category
Documents
-
view
65 -
download
2
Transcript of Introduction to Microsoft Prism
![Page 1: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/1.jpg)
Introduction to Microsoft Prism
Tomaš Maconko
![Page 2: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/2.jpg)
Issue
• We need a HUGE WPF desktop application
• Application must be module-based (plugin-based)
• Modules are developed by different teams in different countries
• Team work is not synchronized
• Application must be tested periodically
![Page 3: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/3.jpg)
Solution
• Easy, but totally not acceptable – decline the project
• Hard, but hardly acceptable – write your own module management infrastructure
• Medium and acceptable – use an already implemented framework for modular applications
![Page 4: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/4.jpg)
Microsoft Prism
• Used in applications consisting of multiple modules
• Contains module management infrastructure
• Provides navigation between views, even if navigation is performed between views from different modules
• Allows application to evolve and enables easy-maintenance
• Currently used in WinRT, WPF, Silverlight and Windows Phone apps
![Page 5: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/5.jpg)
Reusability
• Allows components and services to be developed, tested and integrated into one or more applications
• Reuse of unit-tested components that can be easily discovered and integrated at run time through dependency injection
• Modules can encapsulate application-level capabilities that may be reused across applications
![Page 6: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/6.jpg)
Extensibility
• Allows components to be more easily integrated or replaced with alternative implementations at run time
• Provides the ability to decompose an application into modules that can be independently updated and deployed
• Many of the components in the Prism Library itself can also be extended or replaced
![Page 7: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/7.jpg)
Flexibility
• Allows to extend the application with new capabilities, that can be easily developed and integrated
• Allows WPF applications to be developed using common services and components, allowing the application to be deployed and consumed in the most appropriate way
![Page 8: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/8.jpg)
Team Development
• Allows separate teams to develop and even deploy different parts of the application independently
• Minimizes the cross-team dependencies and allows teams to focus on:• Different functional areas: UI design, business logic implementation,
and infrastructure code development
• Different business-level functional areas: profile, sales, inventory, or logistics
![Page 9: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/9.jpg)
Quality
• Allows common services and components to be fully tested and made available to the development teams
• Allows development teams to focus on their application requirements instead of implementing and testing infrastructure code
![Page 10: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/10.jpg)
Where to use it?
![Page 11: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/11.jpg)
Module management infrastructure
• Load modules immediately or on demand depending on configuration
• There can be no direct/static references between projects
• Modules can be configured through C# code or in configuration file
• Can register each module separately or read all modules from directory
![Page 12: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/12.jpg)
Configuration is simple
![Page 13: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/13.jpg)
Module initialization sequence
1. When application starts BaDemo.Common is initialized as it is static reference.
2. Next BaDemo.Main is loaded, because is should be initialized immediately after startup.
3. A. If the user requested BaDemo.Orders, then both BaDemo.Orders and BaDemo.Items would be initialized, as BaDemo.Orders depends on BaDemo.Items.
4. If the user requested BaDemo.Items, then it is initialized without BaDemo.Orders.
BaDemo
BaDemo.Main
BaDemo.Items
BaDemo.Common
BaDemo.Orders
1. On application start
2. On application start 3a. On requested
4. On requested
3b. On BaDemo.Orders module requested
![Page 14: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/14.jpg)
Other features
• Model-View-ViewModel pattern utilities
• Navigation handling
• Dependency Injection support
• Event aggregation
![Page 15: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/15.jpg)
Model-View-ViewModel
• INotifyPropertyChanged implementation
• ICommand implementation
![Page 16: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/16.jpg)
Navigation handling
• IRegionManager • INavigationAware
![Page 17: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/17.jpg)
Dependency injection support
• Registration • Usage
• Registration can be done in Bootstrapper class or in each module
• Each container provides its own dependency management mechanism:• MEF uses attributes to specify the
exported and imported dependencies• Unity container requires registration
of types and can automatically resolve instances
• And so on...
![Page 18: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/18.jpg)
Event aggregation
![Page 19: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/19.jpg)
Conclusions
• Prism seems to be usable and proper framework for in modular application development
• It contains many tools for easy module management, navigation between modules
• It provides additional tools for MVVM, DI, Event Aggregation and other patterns
• It’s Open Source
![Page 20: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/20.jpg)
Sources
• Prism CodePlex: http://compositewpf.codeplex.com/SourceControl/latest
• MSDN Prism Guide: https://msdn.microsoft.com/en-us/library/ff648465.aspx
• Demo in GitHub: https://github.com/tmaconko/BaDemo
![Page 21: Introduction to Microsoft Prism](https://reader034.fdocuments.us/reader034/viewer/2022042716/55c582e4bb61ebf6388b4610/html5/thumbnails/21.jpg)
Keep #EnjoyITContact me, if you have questions:
• www.ba.lt