Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created June 30, 2010 12:17
Show Gist options
  • Save jfromaniello/458571 to your computer and use it in GitHub Desktop.
Save jfromaniello/458571 to your computer and use it in GitHub Desktop.
public class MyFacility : AbstractFacility
{
protected override void Init()
{
Kernel.ComponentRegistered += Kernel_ComponentRegistered;
}
void Kernel_ComponentRegistered(string key, IHandler handler)
{
if (typeof(MyControllerBase).IsAssignableFrom(handler.Service))
{
handler.ComponentModel.Interceptors
.Add(InterceptorReference.ForType<MyInterceptor>()
.SelectWith(new MyInterceptorSelector()));
}
}
}
public class MyInterceptorSelector : IInterceptorSelector
{
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
if(method.GetCustomAttributes(typeof(MyAttribute), true).Any())
{
return interceptors;
}
return new IInterceptor[]{};
}
}
public class MyAttribute : Attribute
{
}
public class MyInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
throw new NotImplementedException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment