Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (30 sloc) 1.07 KB
using System;
using Rhino.ServiceBus.Config;
using Rhino.ServiceBus.Internal;
using StructureMap;
using StructureMap.Interceptors;
namespace Rhino.ServiceBus.StructureMap
{
[CLSCompliant(false)]
public class ConsumerInterceptor : TypeInterceptor
{
private readonly IConsumerInterceptor interceptor;
private readonly IContainer container;
public ConsumerInterceptor(IConsumerInterceptor interceptor, IContainer container)
{
this.interceptor = interceptor;
this.container = container;
}
public object Process(object target, IContext context)
{
var type = target.GetType();
var lifecycle = container.Model.For(type).Lifecycle;
interceptor.ItemCreated(type, string.IsNullOrEmpty(lifecycle) || lifecycle == "Transient"); //got to be a better way for this
return target;
}
public bool MatchesType(Type type)
{
return typeof(IMessageConsumer).IsAssignableFrom(type);
}
}
}
Something went wrong with that request. Please try again.