2 // System.Runtime.Remoting.Activation.ContextLevelActivator.cs
4 // Author: Lluis Sanchez Gual (lluis@ideary.com)
6 // (C) 2003, Lluis Sanchez Gual
10 using System.Runtime.Remoting.Messaging;
11 using System.Runtime.Remoting.Contexts;
13 namespace System.Runtime.Remoting.Activation
16 internal class ContextLevelActivator: IActivator
18 IActivator m_NextActivator;
20 public ContextLevelActivator (IActivator next)
22 m_NextActivator = next;
25 public ActivatorLevel Level
27 get { return ActivatorLevel.Context; }
30 public IActivator NextActivator
32 get { return m_NextActivator; }
33 set { m_NextActivator = value; }
36 public IConstructionReturnMessage Activate (IConstructionCallMessage ctorCall)
38 ServerIdentity identity = RemotingServices.CreateContextBoundObjectIdentity (ctorCall.ActivationType);
39 RemotingServices.SetMessageTargetIdentity (ctorCall, identity);
41 ConstructionCall call = ctorCall as ConstructionCall;
42 if (call == null || !call.IsContextOk)
44 identity.Context = Context.CreateNewContext (ctorCall);
45 Context oldContext = Context.SwitchToContext (identity.Context);
49 return m_NextActivator.Activate (ctorCall);
53 Context.SwitchToContext (oldContext);
57 return m_NextActivator.Activate (ctorCall);