What should I read?

May 4, 2009 at 10:41 AM
Hi all

I use Unity for dependency injection only at the moment.  It helps me to segment my app more and also to unit test more easily.  Now I'd like to move onto some other capabilities of Unity and would like to know what I should read?  I don't only want to know "this is how to use feature X" I really want to see real-life examples of a feature so that I can see under which circumstances I would consider using it.


May 4, 2009 at 11:44 AM
Have you gone through David Hayden's webcasts? specifically integration with other entlib blocks - http://www.pnpguidance.net/Screencasts.aspx

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
May 4, 2009 at 5:18 PM

It shows how you use it, but as with most things along these lines it doesn't show any valuable scenario in which you might want to.  Logging and timing is all anyone ever demonstrates for AOP, I swear one person thought it up years ago and since then everyone just copies each other's presentations.  Either that or everyone uses it for logging and timing.

I'll move onto some others now :-)
May 7, 2009 at 6:25 AM
I don't have any examples worked up, but I am currently using AOP via Unity for:

* logging of course
* caching
* emailing me when a low volume billing application processes a charge
* incrementing a performance counter
* transaction management e.g. [UnitOfWork]
* enforcing permissions to certain methods
* argument validation e.g. [StrongPasswordValidator] - requires letters and numbers, no sequential or repeats, etc...

I haven't used AOP for any real business logic yet, and I'm not sure if it is a good idea. In addition to AOP, I have been looking for opportunities to take lifetime managment out of my objects. For example, I built a "Forgot Password" feature in an ASP.NET MVC web application that used captcha in the process. I made an ICaptchaProvider that I injected into my controller via Unity. Originally I was accessing the HttpSession object directly from my CaptchaProvider implementation and then it occurred to me that I could simplify my object by using a private member variable and put the onus on the container to inject the correct instance. I did that using an HttpSessionLifetimeManager. I will try to dig up some code for this if you're interested.
May 7, 2009 at 8:55 AM
* transaction management e.g. [UnitOfWork]
This I would like to see because I'd like to know how you get the context of "this is the UoW relating to the current page request".

* enforcing permissions to certain methods
And this one because I'm interested in how you determine who the current user is.
May 9, 2009 at 10:40 PM
Edited May 10, 2009 at 5:35 PM


I posted an answer to your UoW questions with a few code snippets: http://mikevalenty.blogspot.com/2009/05/unit-of-work-with-unity.html

I of glanced over a lot in there, so if you see something of interest let me know and I'll be happy to dig deeper into it. I haven't gotten to the permission question yet, playoff hockey is on and my son is asleep...