4 using System
.Runtime
.Remoting
;
5 using System
.Threading
;
7 using Castle
.Core
.Interceptor
;
11 public class AuditInterceptor
: IInterceptor
13 public void Intercept(IInvocation invocation
)
15 Console
.WriteLine("Intercepted {0}", invocation
.Method
.Name
);
21 [Interceptor(typeof(AuditInterceptor
))]
22 public class Service1
: MarshalByRefObject
24 public virtual void DoOperation()
26 Console
.WriteLine("Done");
30 public interface IService2
35 [Interceptor(typeof(AuditInterceptor
))]
36 public class Service2
: MarshalByRefObject
, IService2
38 public void DoOperation2()
40 Console
.WriteLine("Done2");
46 public static void Main(string[] args
)
48 RemotingConfiguration
.Configure("RemotingTcpConfig.config", false);
50 WindsorContainer container
= new WindsorContainer();
52 container
.AddComponent("interceptor1", typeof(AuditInterceptor
));
53 container
.AddComponent("service1", typeof(Service1
));
54 container
.AddComponent("service2", typeof(IService2
), typeof(Service2
));
56 Service1 serv1
= container
.Resolve
<Service1
>();
57 MarshalByRefObject serv2
=
58 (MarshalByRefObject
) container
.Resolve
<IService2
>();
60 RemotingServices
.Marshal(serv1
, "serv1");
61 RemotingServices
.Marshal(serv2
, "serv2");
63 Thread
.CurrentThread
.Join();