I received a question from a reader asking how one might register a static factory method with Unity to create an object.
The question was in regards to CSLA and how it uses Class In Charge to create, for example, a Customer Class:
public class Customer
{
public static Customer NewCustomer()
{
return new Customer();
}
}
Notice the static method, NewCustomer, that creates a new instance of Customer.
Unity has a separate extension, called StaticFactoryExtension, to help you in these situations. The StaticFactoryExtension is located in the Microsoft.Practices.Unity.StaticFactory.dll Assembly.

Let's go ahead and register the StaticFactoryExtension as well as the method NewCustomer for creating new instances of Customer:
IUnityContainer container = new UnityContainer();
container.AddNewExtension<StaticFactoryExtension>();
container.Configure<IStaticFactoryConfiguration>()
.RegisterFactory<Customer>
(new FactoryDelegate(c => Customer.NewCustomer()));
var customer = container.Resolve<Customer>();
That is all there is to it.
Check out Patterns & Practices Guidance for other Unity Tutorials and Unity Screencasts.
Hope this helps,
David Hayden