using System; using System.Collections; using System.Runtime.CompilerServices; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Contexts; using System.Runtime.Remoting.Messaging; using System.Runtime.Remoting.Proxies; using System.Threading; namespace System.Runtime.Remoting.Activation { // Token: 0x02000383 RID: 899 internal class ActivationServices { // Token: 0x170006CB RID: 1739 // (get) Token: 0x060024F4 RID: 9460 RVA: 0x0007AB98 File Offset: 0x00078D98 private static IActivator ConstructionActivator { get { if (ActivationServices._constructionActivator == null) { ActivationServices._constructionActivator = new ConstructionLevelActivator(); } return ActivationServices._constructionActivator; } } // Token: 0x060024F5 RID: 9461 RVA: 0x0007ABB4 File Offset: 0x00078DB4 public static IMessage Activate(RemotingProxy proxy, ConstructionCall ctorCall) { ctorCall.SourceProxy = proxy; IMessage message; if (Thread.CurrentContext.HasExitSinks && !ctorCall.IsContextOk) { message = Thread.CurrentContext.GetClientContextSinkChain().SyncProcessMessage(ctorCall); } else { message = ActivationServices.RemoteActivate(ctorCall); } if (message is IConstructionReturnMessage && ((IConstructionReturnMessage)message).Exception == null && proxy.ObjectIdentity == null) { Identity messageTargetIdentity = RemotingServices.GetMessageTargetIdentity(ctorCall); proxy.AttachIdentity(messageTargetIdentity); } return message; } // Token: 0x060024F6 RID: 9462 RVA: 0x0007AC34 File Offset: 0x00078E34 public static IMessage RemoteActivate(IConstructionCallMessage ctorCall) { IMessage message; try { message = ctorCall.Activator.Activate(ctorCall); } catch (Exception ex) { message = new ReturnMessage(ex, ctorCall); } return message; } // Token: 0x060024F7 RID: 9463 RVA: 0x0007AC88 File Offset: 0x00078E88 public static object CreateProxyFromAttributes(Type type, object[] activationAttributes) { string text = null; foreach (object obj in activationAttributes) { if (!(obj is IContextAttribute)) { throw new RemotingException("Activation attribute does not implement the IContextAttribute interface"); } if (obj is UrlAttribute) { text = ((UrlAttribute)obj).UrlValue; } } if (text != null) { return RemotingServices.CreateClientProxy(type, text, activationAttributes); } ActivatedClientTypeEntry activatedClientTypeEntry = RemotingConfiguration.IsRemotelyActivatedClientType(type); if (activatedClientTypeEntry != null) { return RemotingServices.CreateClientProxy(activatedClientTypeEntry, activationAttributes); } if (type.IsContextful) { return RemotingServices.CreateClientProxyForContextBound(type, activationAttributes); } return null; } // Token: 0x060024F8 RID: 9464 RVA: 0x0007AD1C File Offset: 0x00078F1C 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; } // Token: 0x060024F9 RID: 9465 RVA: 0x0007AEF8 File Offset: 0x000790F8 public static IMessage CreateInstanceFromMessage(IConstructionCallMessage ctorCall) { object obj = ActivationServices.AllocateUninitializedClassInstance(ctorCall.ActivationType); ServerIdentity serverIdentity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(ctorCall); serverIdentity.AttachServerObject((MarshalByRefObject)obj, Thread.CurrentContext); ConstructionCall constructionCall = ctorCall as ConstructionCall; if (ctorCall.ActivationType.IsContextful && constructionCall != null && constructionCall.SourceProxy != null) { constructionCall.SourceProxy.AttachIdentity(serverIdentity); MarshalByRefObject marshalByRefObject = (MarshalByRefObject)constructionCall.SourceProxy.GetTransparentProxy(); RemotingServices.InternalExecuteMessage(marshalByRefObject, ctorCall); } else { ctorCall.MethodBase.Invoke(obj, ctorCall.Args); } return new ConstructionResponse(obj, null, ctorCall); } // Token: 0x060024FA RID: 9466 RVA: 0x0007AF9C File Offset: 0x0007919C public static object CreateProxyForType(Type type) { ActivatedClientTypeEntry activatedClientTypeEntry = RemotingConfiguration.IsRemotelyActivatedClientType(type); if (activatedClientTypeEntry != null) { return RemotingServices.CreateClientProxy(activatedClientTypeEntry, null); } WellKnownClientTypeEntry wellKnownClientTypeEntry = RemotingConfiguration.IsWellKnownClientType(type); if (wellKnownClientTypeEntry != null) { return RemotingServices.CreateClientProxy(wellKnownClientTypeEntry); } if (type.IsContextful) { return RemotingServices.CreateClientProxyForContextBound(type, null); } return null; } // Token: 0x060024FB RID: 9467 [MethodImpl(MethodImplOptions.InternalCall)] public static extern object AllocateUninitializedClassInstance(Type type); // Token: 0x060024FC RID: 9468 [MethodImpl(MethodImplOptions.InternalCall)] public static extern void EnableProxyActivation(Type type, bool enable); // Token: 0x04000E92 RID: 3730 private static IActivator _constructionActivator; } }