Prism & Silverlight: Part 2 - Dependency Injection with Unity

Play Prism & Silverlight: Part 2 - Dependency Injection with Unity
Sign in to queue


This is part 2 of a series of screencasts illustrating some of the ideas found in "Prism" or the "Composite Application Guidance" from the Patterns and Practices team that can be used to build Silverlight applications in a way that lends itself to testability and modularity.

In talking to customers building business applications with Silverlight I find that Prism (and it's friend Unity) is frequently mentioned but not everyone has seen it and so I thought I would explore it myself and capture some of the results of that exploration here.

We start off with some fairly basic code which we move towards making use of dependency injection and modularity;

and then we move that code into the Silverlight world and try to illustrate some specific areas of Prism;

and then finally we try and bring some of these concepts together in a longer, more realistic example of a simple Email application built using the Prism framework - warning, this is a much longer session but I wanted something that draws things together;

The recommendation would be that you watch the 10 screencasts in order but if that feels like too long a process or if you're already very familiar with concepts like dependency injection and containers like Unity then perhaps watch the last screencast first and then refer back to the previous screencasts if certain areas need more illumination.

I put the source code for Video 10 here for download as it's a bigger set of source and something you might want to explore after the video - this does not necessarily represent "best practise" but is, instead, just meant to illustrate some of the Prism ideas.



Right click to download this episode

The Discussion

  • User profile image

    Excellent video but I'm having a problem with the app.config. I believe mine is correct but as soon as I remove the CalculatorLibrary reference, the InputOutputLibrary reference, or the CalculatorCommandParsingLibrary reference. I get a FileNotFoundException for the reference I remove. Any help would be appreciated.

    Update: I realized that when my references were being deleted that they were deleting the dll's from the bin. All is good now.

  • User profile image

    I am sorry, I may be in the wrong place.  I watched you turn one into five separate projects, for a add, mul, div, sub calculator.  I need to know why I would do such a thing?


    If I have a sidebar with 10 - 12 categories, each responding with 20-100 choices, and all of this before I ever have to respond to the server, Why would I want to take a simple problem and make it complex?


    What I am looking for in Prism "is a way to structure, a complex application with multiple origination points, as well as, multiple departure points.  I am looking for a structure, that isolates individual functions (allowing a copy/replace to the web server without disrupting anyone), barring that I am looking to bring down independant/notify modules for replacement.


    If I understand "Prism", I can loosely couple, and download mismatches.  Is this correct?




    P.S. A better blog would be to give us a real world application (search at every level, lists that bring up specific object type, comboboxes  (with semi-static loading/cacheing), response to selection from a list (fills in source object and returns control), and a step through of the thought process, logic, and implementaion of your solution.



  • User profile image

    Super video series thus far, really enjoying and learning a lot, thanks for sharing ;0)

Add Your 2 Cents