Using Ariane with Unity


Create dependency resolver
public class ServiceBusDependencyResolver : Ariane.IDependencyResolver
{
	public ServiceBusDependencyResolver(Microsoft.Practices.Unity.IUnityContainer container)
	{
		Container = container;
	}

	public Microsoft.Practices.Unity.IUnityContainer Container { get; set; }

	public IEnumerable<object> GetAllServices()
	{
		return Container.Registrations;
	}

	public object GetService(Type serviceType)
	{
		return Container.Resolve(serviceType);
	}

	public IEnumerable<object> GetServices(Type serviceType)
	{
		return Container.ResolveAll(serviceType);
	}
}

Declare the Unity container
var container = new Microsoft.Practices.Unity.UnityContainer();

Register service
container.RegisterType<Ariane.IServiceBus, Ariane.BusManager>(new ContainerControlledLifetimeManager());

Setup dependency resolver
Ariane.GlobalConfiguration.Configuration.DependencyResolver = new ServiceBusDependencyResolver(container);

Last edited Mar 29, 2014 at 11:04 AM by mchouteau, version 2