How can I make use of Microsoft Unity in my Active Commerce implementation?


If you would like to create your own Unity registrations in code, you can create your own implementation of ITypeRegistration in any assembly, and add your registrations within the Process method. Active Commerce will automatically pick up your registrations on startup. You can find more info on this in the Active Commerce Developer's Cookbook included in the Active Commerce download package.

As a reminder, the downloads page is here (restricted to customers and partners):

If you would like to register via configuration, you can add additional registrations within App_Config/Unity.config. You can find more information on the XML configuration format here:

Just keep in mind that you may need to merge your changes with new versions of the file when upgrading.

To grab an object which is constructed from Unity, utilize Sitecore.Ecommerce.Context.Entity.Resolve<T>. You will need to be sure to add a using statement for Microsoft.Practices.Unity to make the shorthand "resolve" syntax available.


using Microsoft.Practices.Unity;
var myobj = Sitecore.Ecommerce.Context.Entity.Resolve<IMyInterface>();
Have more questions? Submit a request