Microsoft CompositeUI Application Block

Originally posted on: http://geekswithblogs.net/gavin/archive/2006/12/27/102130.aspx

I started working on a new project a few weeks ago.  Were writing a new extensible Shell application with the Microsoft CompositeUI Application Block.  I haven’t used this block before.  Looks like Microsoft rushed this thing out the door.  Alot of needed functionality is missing, maybe the goal was to just provide a simple base shell layer and allow developers to extend it to do whatever.  I guess thats how it works when they are trying to release a new pattern or practice. 

So it took me a few weeks to wrap my head around this thing. ObjectBuilder was a new concept for me.  Pretty cool stuff though it turns out, Dependency Injection is a nice way of sharing global objects and making sure everything is referecing the right things.  Here some sample Dependency Injection Code.

Say you create a new object, and you want it to have a reference a global Selection Service..  all you have to do is add this code to your class:

[SmartPart]

public partial class PropertyGridToolWindow : UserControl, ISmartPartInfoProvider

{

   ISelectionService _selectionService;

   [ServiceDependency]

   public ISelectionService SelectionService

   {

   set

   {

   _selectionService = value;

   _selectionService.SelectionChanged += new EventHandler(_selectionService_SelectionChanged);

   }

   get { return _selectionService; }

}

The cool thing about this, is instead of having to create an overloaded constructor to pass the existing instance of the Selection Service to the new object, Object Builder handles it all for you.  When creating the new PropertyGridToolWindow, just have ObjectBuilder do it:

PropertyGridToolWindow _propertyGrid;

_propertyGrid = ModuleWorkItem.SmartParts.AddNew<PropertyGridToolWindow>();

Thats it!  Object Builder will automatically set the reference to the Selection Service when the object is created.

I’ll post some more cool things I discover here as I go.

Gavin

Posting lost in the sea of information…

Originally posted on: http://geekswithblogs.net/gavin/archive/2006/12/21/101849.aspx

Why do we do it?  Why would I even post this blog in the first place?  What does it do for me?  Am I posting, sharing some strange introverted thoughts or ideas that I have no-one else to talk to about?  What are the chances of anything I say here even being read?  You have to ask yourself, If I type and post this blog, and noone ever reads it, will it ever really matter?  I guess if I feel better sharing some specific knowledge I have gained doing something in my life then I will post things.  But, what purpose does it serve other than me sharing my thoughts or experiences with the world? And who knows if anyone even cares about my thoughts or my expereinces. If my blog didn’t exist, and you weren’t here reading it, would it really matter?  I guess it all depends on your perspective of things.  If noone ever wrote a blog, and never posted it for anyone to read, then there would be no blogs and noone reading them, which would, yes, make things different.  So I guess on one hand my contribution to the digital world of information does mean something.  Obviously I’m in a weird mood today, but does it really matter? Not to you….