Using Castle Windsor for DI, I have two classes that implement the same interface; and, in addition, they have some methods and their own properties. I use Castle DynamicProxy and create an Interceptor that will perform some logging with Log4Net through Castle.Facilities.LoggingLoggingFacility.
The log file accurately logs for each method implemented through the interface when this method is called. In the example below, the Foo () method is registered upon invocation, but the LogMeToo () method does not work, because it is not part of the IFoo implementation.
I want other methods that do not implement the interface to register when called. Is this possible, and if so: how?
public interface IFoo
{
void Bar();
}
[Interceptor(typeof(LoggingInterceptor))]
public class Foo : IFoo
{
public void Bar()
{
}
public void LogMeToo()
{
}
}
public static class Program
{
[STAThread]
public static void Start()
{
var container = new WindsorContainer();
container.Register(Component.For<LoggingInterceptor>().LifeStyle.Transient);
container.Register(Component.For<IFoo>().ImplementedBy<Foo>());
container.AddFacility<LoggingFacility>(f => f.LogUsing(LoggerImplementation.Log4net).WithConfig("Log4net.config"));
}
}
WPF C # 4.0