internal static IConstructionReturnMessage DoCrossContextActivation(IConstructionCallMessage reqMsg) { bool isContextful = reqMsg.ActivationType.IsContextful; Context context = null; if (isContextful) { context = new Context(); ArrayList arrayList = (ArrayList)reqMsg.ContextProperties; for (int i = 0; i < arrayList.Count; i++) { IContextProperty contextProperty = arrayList[i] as IContextProperty; if (contextProperty == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute")); } RuntimeAssembly asm = (RuntimeAssembly)contextProperty.GetType().Assembly; ActivationServices.CheckForInfrastructurePermission(asm); if (context.GetProperty(contextProperty.Name) == null) { context.SetProperty(contextProperty); } } context.Freeze(); for (int j = 0; j < arrayList.Count; j++) { if (!((IContextProperty)arrayList[j]).IsNewContextOK(context)) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_PropertyUnhappy")); } } } InternalCrossContextDelegate internalCrossContextDelegate = new InternalCrossContextDelegate(ActivationServices.DoCrossContextActivationCallback); object[] args = new object[] { reqMsg }; IConstructionReturnMessage result; if (isContextful) { result = (Thread.CurrentThread.InternalCrossContextCallback(context, internalCrossContextDelegate, args) as IConstructionReturnMessage); } else { result = (internalCrossContextDelegate(args) as IConstructionReturnMessage); } return(result); }
internal static IConstructionReturnMessage DoCrossContextActivation(IConstructionCallMessage reqMsg) { bool isContextful = reqMsg.ActivationType.IsContextful; Context newCtx = null; if (isContextful) { newCtx = new Context(); ArrayList contextProperties = (ArrayList)reqMsg.ContextProperties; RuntimeAssembly asm = null; for (int i = 0; i < contextProperties.Count; i++) { IContextProperty prop = contextProperties[i] as IContextProperty; if (prop == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute")); } asm = (RuntimeAssembly)prop.GetType().Assembly; CheckForInfrastructurePermission(asm); if (newCtx.GetProperty(prop.Name) == null) { newCtx.SetProperty(prop); } } newCtx.Freeze(); for (int j = 0; j < contextProperties.Count; j++) { if (!((IContextProperty)contextProperties[j]).IsNewContextOK(newCtx)) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_PropertyUnhappy")); } } } InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(ActivationServices.DoCrossContextActivationCallback); object[] args = new object[] { reqMsg }; if (isContextful) { return(Thread.CurrentThread.InternalCrossContextCallback(newCtx, ftnToCall, args) as IConstructionReturnMessage); } return(ftnToCall(args) as IConstructionReturnMessage); }
internal static IConstructionReturnMessage DoCrossContextActivation(IConstructionCallMessage reqMsg) { bool isContextful = reqMsg.ActivationType.IsContextful; Context context = (Context)null; if (isContextful) { context = new Context(); ArrayList arrayList = (ArrayList)reqMsg.ContextProperties; for (int index = 0; index < arrayList.Count; ++index) { IContextProperty prop = arrayList[index] as IContextProperty; if (prop == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute")); } ActivationServices.CheckForInfrastructurePermission((RuntimeAssembly)prop.GetType().Assembly); if (context.GetProperty(prop.Name) == null) { context.SetProperty(prop); } } context.Freeze(); for (int index = 0; index < arrayList.Count; ++index) { if (!((IContextProperty)arrayList[index]).IsNewContextOK(context)) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_PropertyUnhappy")); } } } InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(ActivationServices.DoCrossContextActivationCallback); object[] args = new object[1] { (object)reqMsg }; return(!isContextful?ftnToCall(args) as IConstructionReturnMessage : Thread.CurrentThread.InternalCrossContextCallback(context, ftnToCall, args) as IConstructionReturnMessage); }