Added ifdef DOTNET35
[castle.git] / Experiments / Attic / WindsorAndRemoting / Server / Program.cs
blob962f630b3d757fac76aa3eb3a01a66749af772a6
1 namespace Server
3 using System;
4 using System.Runtime.Remoting;
5 using System.Threading;
6 using Castle.Core;
7 using Castle.Core.Interceptor;
8 using Castle.Windsor;
10 [Transient]
11 public class AuditInterceptor : IInterceptor
13 public void Intercept(IInvocation invocation)
15 Console.WriteLine("Intercepted {0}", invocation.Method.Name);
17 invocation.Proceed();
21 [Interceptor(typeof(AuditInterceptor))]
22 public class Service1 : MarshalByRefObject
24 public virtual void DoOperation()
26 Console.WriteLine("Done");
30 public interface IService2
32 void DoOperation2();
35 [Interceptor(typeof(AuditInterceptor))]
36 public class Service2 : MarshalByRefObject, IService2
38 public void DoOperation2()
40 Console.WriteLine("Done2");
44 class Program
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();