I have been using Structuremap and i have made a an intercepotor to intercept A certain type of Interface to us with events. And when i use the ObjectFactory.WhatDoIHave());
method then the eventhandlers and publishers are all working correct. But when is delete this piece of code then there are no Handlers registered. My interceptor looks like this
public class EventInterceptor : TypeInterceptor
{
public object Process(object target, IContext context)
{
IEventPublisher eventPublisher = context.GetInstance<IEventPublisher>();
eventPublisher.RegisterHandlers(target);
return target;
}
public bool MatchesType(Type type)
{
bool matchesType = type.ImplementsInterfaceTemplate(typeof(IEventHandler<>));
return matchesType;
}
}
What is it that happends in that method that makes my interceptor work ?