Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: da3afc6bd6
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (43 sloc) 1.373 kb
using System;
using System.Collections.Generic;
using System.Linq;
using Castle.MicroKernel.Context;
using Castle.Windsor;
using Rhino.ServiceBus.Impl;
using Rhino.ServiceBus.Internal;
namespace Rhino.ServiceBus.Castle
{
public class CastleServiceLocator : IServiceLocator
{
private readonly IWindsorContainer container;
public CastleServiceLocator(IWindsorContainer container)
{
this.container = container;
}
public T Resolve<T>()
{
return container.Resolve<T>();
}
public object Resolve(Type type)
{
return container.Resolve(type);
}
public bool CanResolve(Type type)
{
return container.Kernel.HasComponent(type);
}
public IEnumerable<T> ResolveAll<T>()
{
return container.ResolveAll<T>();
}
public IEnumerable<IHandler> GetAllHandlersFor(Type type)
{
return (from h in container.Kernel.GetAssignableHandlers(type)
select (IHandler)new DefaultHandler(null, h.ComponentModel.Implementation, () => h.Resolve(new CreationContext(h, container.Kernel.ReleasePolicy, type, null, null, null))));
}
public void Release(object item)
{
container.Kernel.ReleaseComponent(item);
}
}
}
Jump to Line
Something went wrong with that request. Please try again.