Inheritance: System.Runtime.Remoting.Contexts.ContextAttribute, IActivator
Esempio n. 1
0
        public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg)
        {
            if (ctorMsg == null)
            {
                throw new ArgumentNullException("ctorMsg");
            }
            if (ctorMsg.Properties.Contains((object)"Remote"))
            {
                return(LocalActivator.DoRemoteActivation(ctorMsg));
            }
            if (!ctorMsg.Properties.Contains((object)"Permission"))
            {
                return(ctorMsg.Activator.Activate(ctorMsg));
            }
            Type activationType = ctorMsg.ActivationType;

            object[] activationAttributes = (object[])null;
            if (activationType.IsContextful)
            {
                IList contextProperties = ctorMsg.ContextProperties;
                if (contextProperties != null && contextProperties.Count > 0)
                {
                    activationAttributes = new object[1]
                    {
                        (object)new RemotePropertyHolderAttribute(contextProperties)
                    }
                }
                ;
            }
            RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(LocalActivator.GetMethodBase(ctorMsg));

            object[] args      = Message.CoerceArgs((IMethodMessage)ctorMsg, reflectionCachedData.Parameters);
            object   serverObj = Activator.CreateInstance(activationType, args, activationAttributes);

            if (RemotingServices.IsClientProxy(serverObj))
            {
                RedirectionProxy redirectionProxy = new RedirectionProxy((MarshalByRefObject)serverObj, activationType);
                // ISSUE: variable of the null type
                __Null local         = null;
                Type   RequestedType = activationType;
                RemotingServices.MarshalInternal((MarshalByRefObject)redirectionProxy, (string)local, RequestedType);
                serverObj = (object)redirectionProxy;
            }
            return(ActivationServices.SetupConstructionReply(serverObj, ctorMsg, (Exception)null));
        }
Esempio n. 2
0
 public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg)
 {
     if (ctorMsg == null)
     {
         throw new ArgumentNullException("ctorMsg");
     }
     if (ctorMsg.Properties.Contains("Remote"))
     {
         return(LocalActivator.DoRemoteActivation(ctorMsg));
     }
     if (ctorMsg.Properties.Contains("Permission"))
     {
         Type     activationType       = ctorMsg.ActivationType;
         object[] activationAttributes = null;
         if (activationType.IsContextful)
         {
             IList contextProperties = ctorMsg.ContextProperties;
             if (contextProperties != null && contextProperties.Count > 0)
             {
                 RemotePropertyHolderAttribute remotePropertyHolderAttribute = new RemotePropertyHolderAttribute(contextProperties);
                 activationAttributes = new object[]
                 {
                     remotePropertyHolderAttribute
                 };
             }
         }
         MethodBase methodBase = LocalActivator.GetMethodBase(ctorMsg);
         RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(methodBase);
         object[] args = Message.CoerceArgs(ctorMsg, reflectionCachedData.Parameters);
         object   obj  = Activator.CreateInstance(activationType, args, activationAttributes);
         if (RemotingServices.IsClientProxy(obj))
         {
             RedirectionProxy redirectionProxy = new RedirectionProxy((MarshalByRefObject)obj, activationType);
             RemotingServices.MarshalInternal(redirectionProxy, null, activationType);
             obj = redirectionProxy;
         }
         return(ActivationServices.SetupConstructionReply(obj, ctorMsg, null));
     }
     return(ctorMsg.Activator.Activate(ctorMsg));
 }