While trying to tighten down access to invariants within an Aggregate, I'd like to make the exposed collections ReadOnly. Then I control the addition of child objects thru exposed methods, thus enforcing the Aggregate's role as gatekeeper for these objects. The problem is, I am mapping NHibernate to my fields which implement IList which, of course, allow .Add(T entity) and casting to an ReadOnlyCollection in the exposed property isn't going to work.
So I poked around the Algorithms utility class from Wintellect's Power Collections and saw they have a nifty little wrapper that returns an IList for exactly this application. So to lock down my Addresses property that returns an IList, I just have to return Algorithms.ReadOnly(_addresses);.
Now NHibernate is happy and my domain is locked down from dumb mistakes I might make trying to add a child to a collection without following biz rules.
I love these little utilities the Wintellect guys put out there...real handy. They are fast and handy.