Saturday, March 22, 2008

Auto-wiring an MVC Triad using Unity

I think this post's title is a little bit cryptic, but if you did understood my intentions; you are possibly an IoC geek and may be you know what I am trying to say here.

So, let me explain the phrase from right to left:

Unity: The Unity Application Block (Unity) is a lightweight, extensible dependency injection container with support for constructor, property, and method call injection; it will be part of Entrprise Library version 4.0 and it has its own space on codeplex ( )

MVC : The famous Model-View-Controller design pattern used in the presentation layer since its invention in the 70s.

Wiring: The MVC pattern requires 3 classes to exist and coordinate together, the Controller class will need an instance of the Model and View, and the View will need a reference to the Model so it can handle the display of the Model.

In the normal life of any MVC based application, we will need some code like this:

Model m = new Model();

View v = new View();

Controller c = new Controller ( m , v);


By this; I mean wiring the classes together so they will be able to communicate.

Auto-Wiring: Is the mechanism of automatically wiring the classes together without the need to write the above code again and again.

One of the auto-wiring techniques is to use the Dependency Injection pattern, and instead of building my own implementation of it, I am using the Unit Application Block.

Unity is able to discover the dependency of the classes based on their constructors, so in the above example; Unity will discover that Controller will need a Model and a View instance so the Controller can be instantiated, and also the same for the View.

Using Unity, all what is needed is to call the Resolve method in the UnityContainer and it will instantiate all the dependencies for us (namely the Model and the View), and will instantiate the controller and pass it the created instances auto-magically.

UnityContainer container = new UnityContainer();

Controller c = container.Resolve<Controller>();


I have made a sample application, you can check to see the above code into action. You will need VS2008,no need to download or setup Unity, since its assemblies are included.

Agree, Disagree? I like to hear your comments.

Thursday, March 20, 2008

powercfg -H ON

Today I run out of space on my C: drive, so I used the Desk Clean up wizard to free some desk space for me, it asked me to clean many things and I blindly checked them all.

Then when I tried to Hibernate the computer, I didn't find the Hibernate option.

Thanks Google, I found a Microsoft KB Article (The Hibernate option is not available in Windows Vista

The article says "This issue occurs if one of the following conditions is true: 1) The Disk Cleanup Utility and has been used to delete the Hibernation File Cleaner. " and there are some other conditions ... but what I did to clean my disk space prevented me from Hibernation !!!!

Hmmm, Is it my fault any way ... I shouldn't check all the items in the wizard :(

Oh, I forgot to tell you how to get Hibernate again ... on the command prompt type:

powercfg -H ON

Wednesday, March 12, 2008

Hacking my kids games

Sometimes you feel that the geek inside you is about to explode , this happened to me when I went to buy a new toy to my daughter from the toy store and seen the RC Cars.

I found cheap remote controlled cars for less than 100 LE ( < 15$ )

The toy cars are remotely controlled using Radio frequency, they are called RC Cars for (Radio Controlled Cars)

Once I seen the remote control, I though immediately if it is possible to connect that remote to my PC and control the car using my keyboard !!! why do that ... I don't know but read the article from the beginning again and you will understand.

So, I did a quick search and I found other geeks thinking in the same line, this post ( is what I was looking for and this ( is the circuit used to connect the remote to the computer parallel port.

As soon as I do that , will let you all know :)

Extreme XML

lots of interesting articles about XML, XPath , XSLT for .net developers:

Check them out

Monday, March 03, 2008

Microsoft Robotics Studio Links


MSDN Robotics Forums


Microsoft Robotics Downloads

Introductory Courseware for Microsoft Robotics Studio


Channel 9 Videos

Robots and BizTalk Services

Microsoft Robotics Studio and Lego Mindstorms NXT

Microsoft Robotics Tour:

Part 1:CCR, VPL, Simulation -

Part 2:CCR, VPL, Simulation -

Singapore Sumo-Robot How-To

#1: Getting the Robotics Bits

#2: Understanding Your Robot's Inputs and Outputs

#3: Building Your First Robot

#4: Understanding Your Robot's Code Methods




CCR Programming - Jeffrey Richter and George Chrysanthakopoulos

Microsoft Robotics Studio



Walter Stiers - Academic Relations Team (BeLux)



Windows Embedded Academic Program (WEMAP)
The Windows Embedded Academic Program (WEMAP) helps provide a better understanding of the Windows CE and Windows XP Embedded operating systems to academia. As a participant in this program, you can learn how to educate the next generation of embedded developers on Windows Embedded technologies. You can participate in a variety of programs, including student competitions like the Windows Embedded Student ChallengE and discounted hardware programs, such as the Hardware Empowerment Program.


HowTo Videos: Robotics and .Net fundamentals