- () Dynamic Proxy Castle. , /- , , . , , "" - , , , . , :
public class LoggingInterceptor : IInterceptor
{
public void Intercept(IInvocation call)
{
MyLogger.Info("Starting call: " + call.Method.Name);
call.Proceed();
MyLogger.Info("Finished call: " + call.Method.Name);
}
}
, . , :
using Castle.DynamicProxy;
...
ProxyGenerator generator = new ProxyGenerator();
RawDataService service = new RawDataService();
RawDataService proxy = generator.CreateClassProxyWithTarget<RawDataService>(
service,
new LoggingInterceptor());
WebServiceHost host = new WebServiceHost(proxy, new Uri(baseAddress));
... rest of your code as it was ...
, RawDataService, Intercept(), Proceed(), . , , StopWatch log, , .
. "" IoC /- , , . AOP-: