Using Configuration to Register Instances

Sep 9, 2008 at 3:05 PM

Hi,

I would like to replicate the following code using Unity.Configuration (config file) rather than hard coding it. Could anyone help me?

IViewModel viewModel;
container.RegisterType<IViewModel, OrderViewModel>();
viewModel = container.Resolve<IViewModel>();
container.RegisterInstance<IOrderService>(viewModel);

The above secenario is part of a CompositeWPF application where IOrderService is responsible for publishing events, such as CustomerContextChangedEvent. Other types (again resolved using the same container) subscribe to these events by referencing IOrderService as part of their Constructor (e.g. AnotherThing(IOrderService orderService)) or using Unity Dependency Injection.


Thanks
Richie