public static ConstructionCall CreateConstructionCall(Type type, string activationUrl, object[] activationAttributes)
        {
            ConstructionCall constructionCall = new ConstructionCall(type);

            if (!type.IsContextful)
            {
                constructionCall.Activator   = new AppDomainLevelActivator(activationUrl, ActivationServices.ConstructionActivator);
                constructionCall.IsContextOk = false;
                return(constructionCall);
            }
            IActivator activator = ActivationServices.ConstructionActivator;

            activator = new ContextLevelActivator(activator);
            ArrayList arrayList = new ArrayList();

            if (activationAttributes != null)
            {
                arrayList.AddRange(activationAttributes);
            }
            bool    flag           = activationUrl == ChannelServices.CrossContextUrl;
            Context currentContext = Thread.CurrentContext;

            if (flag)
            {
                foreach (object obj in arrayList)
                {
                    IContextAttribute contextAttribute = (IContextAttribute)obj;
                    if (!contextAttribute.IsContextOK(currentContext, constructionCall))
                    {
                        flag = false;
                        break;
                    }
                }
            }
            object[] customAttributes = type.GetCustomAttributes(true);
            foreach (object obj2 in customAttributes)
            {
                if (obj2 is IContextAttribute)
                {
                    flag = (flag && ((IContextAttribute)obj2).IsContextOK(currentContext, constructionCall));
                    arrayList.Add(obj2);
                }
            }
            if (!flag)
            {
                constructionCall.SetActivationAttributes(arrayList.ToArray());
                foreach (object obj3 in arrayList)
                {
                    IContextAttribute contextAttribute2 = (IContextAttribute)obj3;
                    contextAttribute2.GetPropertiesForNewContext(constructionCall);
                }
            }
            if (activationUrl != ChannelServices.CrossContextUrl)
            {
                activator = new AppDomainLevelActivator(activationUrl, activator);
            }
            constructionCall.Activator   = activator;
            constructionCall.IsContextOk = flag;
            return(constructionCall);
        }
Beispiel #2
0
 internal static void GetPropertiesFromAttributes(IConstructionCallMessage ctorMsg, object[] attributes)
 {
     if (attributes != null)
     {
         for (int i = 0; i < attributes.Length; i++)
         {
             IContextAttribute attribute = attributes[i] as IContextAttribute;
             if (attribute == null)
             {
                 throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute"));
             }
             RuntimeAssembly asm = (RuntimeAssembly)attribute.GetType().Assembly;
             CheckForInfrastructurePermission(asm);
             attribute.GetPropertiesForNewContext(ctorMsg);
         }
     }
 }
 internal static void GetPropertiesFromAttributes(IConstructionCallMessage ctorMsg, object[] attributes)
 {
     if (attributes == null)
     {
         return;
     }
     for (int index = 0; index < attributes.Length; ++index)
     {
         IContextAttribute contextAttribute = attributes[index] as IContextAttribute;
         if (contextAttribute == null)
         {
             throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute"));
         }
         ActivationServices.CheckForInfrastructurePermission((RuntimeAssembly)contextAttribute.GetType().Assembly);
         contextAttribute.GetPropertiesForNewContext(ctorMsg);
     }
 }