public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg) { if (ctorMsg.Properties.Contains("Remote")) { string remActivatorURL = (string)ctorMsg.Properties["Remote"]; AppDomainLevelActivator appDomainLevelActivator = new AppDomainLevelActivator(remActivatorURL); IActivator activator = ctorMsg.Activator; if (activator.Level < ActivatorLevel.AppDomain) { appDomainLevelActivator.NextActivator = activator; ctorMsg.Activator = appDomainLevelActivator; return; } if (activator.NextActivator == null) { activator.NextActivator = appDomainLevelActivator; return; } while (activator.NextActivator.Level >= ActivatorLevel.AppDomain) { activator = activator.NextActivator; } appDomainLevelActivator.NextActivator = activator.NextActivator; activator.NextActivator = appDomainLevelActivator; } }
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); }
public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg) { if (!ctorMsg.Properties.Contains((object)"Remote")) { return; } AppDomainLevelActivator domainLevelActivator = new AppDomainLevelActivator((string)ctorMsg.Properties[(object)"Remote"]); IActivator activator = ctorMsg.Activator; if (activator.Level < ActivatorLevel.AppDomain) { domainLevelActivator.NextActivator = activator; ctorMsg.Activator = (IActivator)domainLevelActivator; } else if (activator.NextActivator == null) { activator.NextActivator = (IActivator)domainLevelActivator; } else { while (activator.NextActivator.Level >= ActivatorLevel.AppDomain) { activator = activator.NextActivator; } domainLevelActivator.NextActivator = activator.NextActivator; activator.NextActivator = (IActivator)domainLevelActivator; } }
public static ConstructionCall CreateConstructionCall(Type type, string activationUrl, object[] activationAttributes) { ConstructionCall ctorCall = new ConstructionCall(type); if (!type.IsContextful) { // Must be a remote activated object ctorCall.Activator = new AppDomainLevelActivator(activationUrl, ConstructionActivator); ctorCall.IsContextOk = false; // It'll be activated in a remote context return(ctorCall); } // It is a CBO. Need collect context properties and // check if a new context is needed. IActivator activatorChain = ConstructionActivator; activatorChain = new ContextLevelActivator(activatorChain); ArrayList attributes = new ArrayList(); if (activationAttributes != null) { attributes.AddRange(activationAttributes); } bool isContextOk = (activationUrl == ChannelServices.CrossContextUrl); // Remote CBOs are always created in a new context Context currentContext = Threading.Thread.CurrentContext; if (isContextOk) { foreach (IContextAttribute attr in attributes) { if (!attr.IsContextOK(currentContext, ctorCall)) { isContextOk = false; break; } } } object[] typeAttributes = type.GetCustomAttributes(true); foreach (object attr in typeAttributes) { if (attr is IContextAttribute) { isContextOk = isContextOk && ((IContextAttribute)attr).IsContextOK(currentContext, ctorCall); attributes.Add(attr); } } if (!isContextOk) { // A new context is needed. Collect the context properties and chain // the context level activator. ctorCall.SetActivationAttributes(attributes.ToArray()); foreach (IContextAttribute attr in attributes) { attr.GetPropertiesForNewContext(ctorCall); } } if (activationUrl != ChannelServices.CrossContextUrl) { activatorChain = new AppDomainLevelActivator(activationUrl, activatorChain); } ctorCall.Activator = activatorChain; ctorCall.IsContextOk = isContextOk; return(ctorCall); }
public override void GetPropertiesForNewContext( IConstructionCallMessage ctorMsg) { BCLDebug.Log("ActivationSvc:GlobalAttrib::GetPropForNewCtx"); // This is called during RS::Activate .. when we are sure that // activation is at least x-context and this is a real activation // instead of a spoofed connect underneath the "new". Contract.Assert(ctorMsg!=null, "ctorMsg null?"); if (ctorMsg.Properties.Contains(ActivationServices.RemoteActivateKey)) { // Means we did want to intercept activation! String remActivatorURL = (String) ctorMsg.Properties[ActivationServices.RemoteActivateKey]; AppDomainLevelActivator activator = new AppDomainLevelActivator(remActivatorURL); // Chain ourselves at the end of the AppDomainLevel activators Contract.Assert( ctorMsg.Activator != null, "Should have at least x-context activator"); IActivator curr = ctorMsg.Activator; if (curr.Level < ActivatorLevel.AppDomain) { // Common case .. .only x-context activator(s) in chain activator.NextActivator = curr; ctorMsg.Activator = activator; } else if (curr.NextActivator == null) { // Only one activator but not ContextLevel ... // We go at the end of the chain curr.NextActivator = activator; } else { // We will have to walk the chain till the end of the last // AD activator and plug ourselves in. while (curr.NextActivator.Level >= ActivatorLevel.AppDomain) { curr = curr.NextActivator; } Contract.Assert( curr.NextActivator.Level.Equals(ActivatorLevel.Context), "bad ordering of activators!"); activator.NextActivator = curr.NextActivator; curr.NextActivator = activator; } } }
public static ConstructionCall CreateConstructionCall (Type type, string activationUrl, object[] activationAttributes) { ConstructionCall ctorCall = new ConstructionCall (type); if (!type.IsContextful) { // Must be a remote activated object ctorCall.Activator = new AppDomainLevelActivator (activationUrl, ConstructionActivator); ctorCall.IsContextOk = false; // It'll be activated in a remote context return ctorCall; } // It is a CBO. Need collect context properties and // check if a new context is needed. IActivator activatorChain = ConstructionActivator; activatorChain = new ContextLevelActivator (activatorChain); ArrayList attributes = new ArrayList (); if (activationAttributes != null) attributes.AddRange (activationAttributes); bool isContextOk = (activationUrl == ChannelServices.CrossContextUrl); // Remote CBOs are always created in a new context Context currentContext = Threading.Thread.CurrentContext; if (isContextOk) { foreach (IContextAttribute attr in attributes) { if (!attr.IsContextOK (currentContext, ctorCall)) { isContextOk = false; break; } } } object[] typeAttributes = type.GetCustomAttributes (true); foreach (object attr in typeAttributes) { if (attr is IContextAttribute) { isContextOk = isContextOk && ((IContextAttribute)attr).IsContextOK (currentContext, ctorCall); attributes.Add (attr); } } if (!isContextOk) { // A new context is needed. Collect the context properties and chain // the context level activator. ctorCall.SetActivationAttributes (attributes.ToArray()); foreach (IContextAttribute attr in attributes) attr.GetPropertiesForNewContext (ctorCall); } if (activationUrl != ChannelServices.CrossContextUrl) activatorChain = new AppDomainLevelActivator (activationUrl, activatorChain); ctorCall.Activator = activatorChain; ctorCall.IsContextOk = isContextOk; return ctorCall; }
public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg) { if (ctorMsg.Properties.Contains("Remote")) { string remActivatorURL = (string) ctorMsg.Properties["Remote"]; AppDomainLevelActivator activator = new AppDomainLevelActivator(remActivatorURL); IActivator nextActivator = ctorMsg.Activator; if (nextActivator.Level < ActivatorLevel.AppDomain) { activator.NextActivator = nextActivator; ctorMsg.Activator = activator; } else if (nextActivator.NextActivator != null) { while (nextActivator.NextActivator.Level >= ActivatorLevel.AppDomain) { nextActivator = nextActivator.NextActivator; } activator.NextActivator = nextActivator.NextActivator; nextActivator.NextActivator = activator; } else { nextActivator.NextActivator = activator; } } }