public virtual void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
 {
     for (int i = 0; i < this._cp.Count; i++)
     {
         ctorMsg.ContextProperties.Add(this._cp[i]);
     }
 }
 internal static IConstructionReturnMessage Activate(RemotingProxy remProxy, IConstructionCallMessage ctorMsg)
 {
     IConstructionReturnMessage message = null;
     if (((ConstructorCallMessage) ctorMsg).ActivateInContext)
     {
         message = ctorMsg.Activator.Activate(ctorMsg);
         if (message.Exception != null)
         {
             throw message.Exception;
         }
         return message;
     }
     GetPropertiesFromAttributes(ctorMsg, ctorMsg.CallSiteActivationAttributes);
     GetPropertiesFromAttributes(ctorMsg, ((ConstructorCallMessage) ctorMsg).GetWOMAttributes());
     GetPropertiesFromAttributes(ctorMsg, ((ConstructorCallMessage) ctorMsg).GetTypeAttributes());
     IMethodReturnMessage message2 = (IMethodReturnMessage) Thread.CurrentContext.GetClientContextChain().SyncProcessMessage(ctorMsg);
     message = message2 as IConstructionReturnMessage;
     if (message2 == null)
     {
         throw new RemotingException(Environment.GetResourceString("Remoting_Activation_Failed"));
     }
     if (message2.Exception != null)
     {
         throw message2.Exception;
     }
     return message;
 }
		public IConstructionReturnMessage Activate (IConstructionCallMessage ctorCall)
		{
			IConstructionReturnMessage response;

			// Create the object by calling the remote activation service

			IActivator remoteActivator = (IActivator) RemotingServices.Connect (typeof (IActivator), _activationUrl);
			ctorCall.Activator = ctorCall.Activator.NextActivator;

			try
			{
				response = remoteActivator.Activate (ctorCall);
			}
			catch (Exception ex)
			{
				return new ConstructionResponse (ex, ctorCall);
			}

			// Create the client identity for the remote object

			ObjRef objRef = (ObjRef) response.ReturnValue;
			if (RemotingServices.GetIdentityForUri (objRef.URI) != null)
				throw new RemotingException("Inconsistent state during activation; there may be two proxies for the same object");

			object proxy;
			
			// We pass null for proxyType because we don't really to attach the identity
			// to a proxy, we already have one.
			Identity identity = RemotingServices.GetOrCreateClientIdentity (objRef, null, out proxy);
			RemotingServices.SetMessageTargetIdentity (ctorCall, identity);
			return response;
		}
		/// <summary>
		/// Adds the current context property to the given message.
		/// </summary>
		/// <param name="ctorMsg">The <see cref="T:System.Runtime.Remoting.Activation.IConstructionCallMessage"/> to which to add the context property.</param>
		/// <exception cref="T:System.ArgumentNullException">
		/// The <paramref name="ctorMsg"/> parameter is null.
		/// </exception>
		/// <PermissionSet>
		/// 	<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure"/>
		/// </PermissionSet>
		public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
		{
			if (AspectConfiguration.Instance.Enabled)
			{
				ctorMsg.ContextProperties.Add(new AspectProperty());
			}
		}
 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;
         }
     }
 }
Exemple #6
0
        public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg)
        {
            IConstructionCallMessage constructionCallMessage = ctorMsg;
            IActivator nextActivator = constructionCallMessage.Activator.NextActivator;

            constructionCallMessage.Activator = nextActivator;
            return(ActivationServices.DoServerContextActivation(ctorMsg));
        }
        internal static IConstructionReturnMessage DoServerContextActivation(IConstructionCallMessage reqMsg)
        {
            Exception e = null;
            Type      activationType = reqMsg.ActivationType;
            object    serverObj      = ActivationServices.ActivateWithMessage(activationType, reqMsg, null, out e);

            return(ActivationServices.SetupConstructionReply(serverObj, reqMsg, e));
        }
 public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
 {
     // We are not interested in contributing any properties to the
     // new context since the only purpose of this property is to force
     // the creation of the context and the server object inside it at
     // the specified URL.
     return;
 }
Exemple #9
0
        /// <summary>
        /// 指定されたコンストラクターを呼び出します。
        /// </summary>
        /// <param name="ctorCall">メソッドの呼び出しに関する情報を格納している <see cref="IConstructionCallMessage"/>。</param>
        /// <returns>呼び出されたメソッドが返す <see cref="IConstructionReturnMessage"/>。</returns>
        private IConstructionReturnMessage InvokeConstructor(IConstructionCallMessage ctorCall)
        {
            var ctorReturn = InitializeServerObject(ctorCall);

            Target = GetUnwrappedServer() as T;
            SetStubData(this, Target);
            return(ctorReturn);
        }
Exemple #10
0
 public virtual void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
 {
     if (ctorMsg == null)
     {
         throw new ArgumentNullException("ctorMsg");
     }
     ctorMsg.ContextProperties.Add(this);
 }
 public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
 {
     // We are not interested in contributing any properties to the
     // new context since the only purpose of this property is to force
     // the creation of the context and the server object inside it at
     // the specified URL.
     return;
 }
Exemple #12
0
        private IConstructionReturnMessage InternalActivate(IConstructionCallMessage ctorMsg)
        {
            this.CtorThread = Thread.CurrentThread.GetHashCode();
            IConstructionReturnMessage message = ActivationServices.Activate(this, ctorMsg);

            base.Initialized = true;
            return(message);
        }
        public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
        {
            if (ctorMsg == null)
                throw new ArgumentNullException("ctorMsg");

            IContextProperty cachedProperty = new CachedContextProperty();
            ctorMsg.ContextProperties.Add(cachedProperty);
        }
 public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
 {
     if (ctorMsg == null)
     {
         throw new ArgumentNullException("ctorMsg");
     }
     ctorMsg.ContextProperties.Add(new ContributeInstallContextSynchronizationContextMessageSink());
 }
		public void GetPropertiesForNewContext(IConstructionCallMessage ctor)
		{
			if (_contextProperties != null)
			{
				foreach (object prop in _contextProperties)
					ctor.ContextProperties.Add (prop);
			}
		}
            /// <summary>
            /// Invokes the message.
            /// </summary>
            /// <param name="msg">The message.</param>
            /// <returns>The result of invocation.</returns>
            public override IMessage Invoke(IMessage msg)
            {
                IConstructionCallMessage constructorCall = msg as IConstructionCallMessage;

                if (constructorCall != null)
                {
                    if (this.target == null)
                    {
                        MethodInfo factoryMethodInfo = Utility.GetInheritedMethod(constructorCall.ActivationType, DynamicConstructionAttribute.InstantiateMethodName, new[] { typeof(Type), typeof(object[]) });

                        if (factoryMethodInfo == null)
                        {
                            throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Cannot create an instance of type '{0}' because there is no '{1}' static method defined in its inheritance hierarchy. See '{2}' methods for an example of corresponding method signature.", constructorCall.ActivationType.AssemblyQualifiedName, DynamicConstructionAttribute.InstantiateMethodName, typeof(LiveTest).AssemblyQualifiedName));
                        }

                        if (!DynamicConstructionAttribute.EnterInstantiationPhase())
                        {
                            throw new InvalidOperationException("Error in instantiation workflow. Object is already in the middle of instantiation when another instance of the object is created.");
                        }

                        try
                        {
                            this.target = (LiveTest)factoryMethodInfo.Invoke(null, new object[] { constructorCall.ActivationType, constructorCall.Args });
                        }
                        finally
                        {
                            DynamicConstructionAttribute.LeaveInstantiationPhase();
                        }
                    }

                    return(EnterpriseServicesHelper.CreateConstructionReturnMessage(constructorCall, (MarshalByRefObject)this.GetTransparentProxy()));
                }

                IMethodCallMessage methodCall = msg as IMethodCallMessage;

                if (methodCall != null)
                {
                    methodCall = new MethodCall(methodCall);

                    MethodCallEventArgs eventArgs = typeof(LiveTest).IsAssignableFrom(methodCall.MethodBase.DeclaringType) ? new MethodCallEventArgs(Interlocked.Increment(ref methodCallId), methodCall.MethodBase, methodCall.Args) : null;

                    if (eventArgs != null)
                    {
                        this.target.OnBeforeMethodCall(this.target, eventArgs);
                    }

                    IMessage result = RemotingServices.GetRealProxy(this.target).Invoke(methodCall);

                    if (eventArgs != null)
                    {
                        this.target.OnAfterMethodCall(this.target, eventArgs);
                    }

                    return(result);
                }

                throw new NotSupportedException("Operations other than constructor and method calls are not supported.");
            }
        /// <summary>
        /// 构造函数代理方法执行.
        /// </summary>
        /// <param name="methodInvoke">代理目标方法</param>
        /// <returns>代理结果</returns>
        public virtual IMessage ProcessConstruct(IMessage methodInvoke)
        {
            IConstructionCallMessage   constructCallMsg          = methodInvoke as IConstructionCallMessage;
            IConstructionReturnMessage constructionReturnMessage = this.InitializeServerObject((IConstructionCallMessage)methodInvoke);

            RealProxy.SetStubData(this, constructionReturnMessage.ReturnValue);

            return(constructionReturnMessage);
        }
        //Le runtime .NET interroge pour savoir si le contexte courant est valide.
        //Si cette fonction false, le runtime créé un nouveau contexte et appelle GetPropertiesForNewContext()
        // pour vérifier si le context est valid, on vérifie la présence (et la validité si besoin) d'un propriété
        public override bool IsContextOK(Context ctx,IConstructionCallMessage ctorMsg)
        {
            //return false;	// Seulement si vous souhaitez un contexte par instance !
            DataValidationProperty prop=ctx.GetProperty("DataValidation") as DataValidationProperty;
            if (prop!=null)	// on a une propriété appelé ValidationData dans le contexte ?
                return true;	// Oui -> on accepte le contexte

            return false;	// Non -> on refuse le contexte
        }
Exemple #19
0
        public static IConstructionReturnMessage DoSimpleXADActivation(IConstructionCallMessage msg)
        {
            int       domain_no = Interlocked.Increment(ref _domain_no);
            AppDomain ad        = AppDomain.CreateDomain("AutoDomain #" + domain_no, null, null);

            activator a = (activator)(ad.CreateInstance(null, typeof(activator).FullName)).Unwrap();

            return(a.Activate(msg));
        }
	// Get the properties for a new construction context.
	public virtual void GetPropertiesForNewContext
				(IConstructionCallMessage ctorMsg)
			{
				if(ctorMsg == null)
				{
					throw new ArgumentNullException("ctorMsg");
				}
				ctorMsg.ContextProperties.Add(this);
			}
 private static MethodBase GetMethodBase(IConstructionCallMessage msg)
 {
     MethodBase methodBase = msg.MethodBase;
     if (null == methodBase)
     {
         throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Message_MethodMissing"), new object[] { msg.MethodName, msg.TypeName }));
     }
     return methodBase;
 }
 public override bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg)
 {
     var p = ctx.GetProperty("Reporting") as ReportingProperty;
     if (p == null)
     {
         return false;
     }
     return true;
 }
Exemple #23
0
        public override IMessage Invoke(IMessage msg)
        {
            //throw new NotImplementedException();

            IMethodCallMessage       call = (IMethodCallMessage)msg;
            IConstructionCallMessage ctor = call as IConstructionCallMessage;
            IMethodReturnMessage     back = null;

            //filter method
            object[] attrs       = call.MethodBase.GetCustomAttributes(typeof(BusinessMethodAttribute), true);
            bool     isAopMethod = attrs.Length > 0;

            if (ctor != null)
            {
                //构造开始时
                //do something
                if (this.EventConstructionBegin != null)
                {
                    this.EventConstructionBegin(msg, back, this._target, null);
                }

                //执行远程对象构造方法
                MarshalByRefObject mbro      = this.GetTransparentProxy() as MarshalByRefObject;
                RealProxy          realProxy = RemotingServices.GetRealProxy(this._target);
                realProxy.InitializeServerObject(ctor);
                back = EnterpriseServicesHelper.CreateConstructionReturnMessage(ctor, mbro);

                //构造结束时
                //do something
                if (this.EventConstructionEnd != null)
                {
                    this.EventConstructionEnd(msg, back, this._target, null);
                }

                return(back);
            }


            //方法执行开始时
            //do something
            if (this.EventMethodBegin != null && isAopMethod)
            {
                this.EventMethodBegin(msg, back, this._target, attrs[0] as BusinessMethodAttribute);
            }

            //执行远程对象方法
            back = RemotingServices.ExecuteMessage(this._target, call);

            //方法执行结束时
            //do something
            if (this.EventMethodEnd != null && isAopMethod)
            {
                this.EventMethodEnd(msg, back, this._target, attrs[0] as BusinessMethodAttribute);
            }
            return(back);
        }
Exemple #24
0
        public override IMessage Invoke(IMessage msg)
        {
            IMessage             retMsg       = null;
            IMethodCallMessage   methodCall   = (IMethodCallMessage)msg;
            IMethodReturnMessage methodReturn = null;

            object[] copiedArgs = Array.CreateInstance(typeof(object), methodCall.Args.Length) as object[];
            methodCall.Args.CopyTo(copiedArgs, 0);
            List <RaiseEventAttribute> eventRaisors = null;

            if (msg is IConstructionCallMessage)
            {
                IConstructionCallMessage ccm = (IConstructionCallMessage)msg;
                RemotingServices.GetRealProxy(target).InitializeServerObject(ccm);
                ObjRef oRef = RemotingServices.Marshal(target);
                RemotingServices.Unmarshal(oRef);
                retMsg = EnterpriseServicesHelper.CreateConstructionReturnMessage(ccm, (MarshalByRefObject)this.GetTransparentProxy());
            }
            else
            {
                IMethodCallMessage mcm   = (IMethodCallMessage)msg;
                object[]           attrs = methodCall.MethodBase.GetCustomAttributes(typeof(RaiseEventAttribute), false);
                if (attrs != null && attrs.Count() > 0)
                {
                    eventRaisors = new List <RaiseEventAttribute>();
                    foreach (object att in attrs)
                    {
                        eventRaisors.Add((RaiseEventAttribute)attrs[0]);
                    }
                }

                try
                {
                    object returnValue = methodCall.MethodBase.Invoke(this.target, copiedArgs);
                    methodReturn = new ReturnMessage(returnValue, copiedArgs, copiedArgs.Length, methodCall.LogicalCallContext, methodCall);

                    if (eventRaisors != null)
                    {
                        eventRaisors.ForEach(t => SysRuntime.EventBus.RaiseEvent(t.EventType, null));
                    }
                }
                catch (Exception ex)
                {
                    if (null != ex.InnerException)
                    {
                        methodReturn = new ReturnMessage(ex.InnerException, methodCall);
                    }
                    else
                    {
                        methodReturn = new ReturnMessage(ex, methodCall);
                    }
                }
                retMsg = methodReturn;
            }
            return(retMsg);
        }
        internal IMessage NotifyActivatorProperties(IMessage msg, bool bServerSide)
        {
            IMessage message = null;

            try
            {
                int    index = this._numCtxProps;
                object obj2  = null;
                while (index-- != 0)
                {
                    obj2 = this._ctxProps[index];
                    IContextPropertyActivator activator = obj2 as IContextPropertyActivator;
                    if (activator != null)
                    {
                        IConstructionCallMessage message2 = msg as IConstructionCallMessage;
                        if (message2 != null)
                        {
                            if (!bServerSide)
                            {
                                activator.CollectFromClientContext(message2);
                            }
                            else
                            {
                                activator.DeliverClientContextToServerContext(message2);
                            }
                        }
                        else if (bServerSide)
                        {
                            activator.CollectFromServerContext((IConstructionReturnMessage)msg);
                        }
                        else
                        {
                            activator.DeliverServerContextToClientContext((IConstructionReturnMessage)msg);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                IMethodCallMessage mcm = null;
                if (msg is IConstructionCallMessage)
                {
                    mcm = (IMethodCallMessage)msg;
                }
                else
                {
                    mcm = new ErrorMessage();
                }
                message = new ReturnMessage(exception, mcm);
                if (msg != null)
                {
                    ((ReturnMessage)message).SetLogicalCallContext((LogicalCallContext)msg.Properties[Message.CallContextKey]);
                }
            }
            return(message);
        }
Exemple #26
0
        public override bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg)
        {
            var p = ctx.GetProperty("Reporting") as ReportingProperty;

            if (p == null)
            {
                return(false);
            }
            return(true);
        }
 public void GetPropertiesForNewContext(IConstructionCallMessage ctor)
 {
     if (this._contextProperties != null)
     {
         foreach (object value in this._contextProperties)
         {
             ctor.ContextProperties.Add(value);
         }
     }
 }
 public override void GetPropertiesForNewContext(IConstructionCallMessage msg)
 {
     //Make sure we have a valid construction call message
     if (msg == null)
     {
         throw new ArgumentNullException("msg");
     }
     msg.ContextProperties.Add(new TestProperty <SpiraTestCaseAspect>());
     msg.ContextProperties.Add(new TestProperty <SpiraTestConfigurationAspect>());
 }
Exemple #29
0
        // Token: 0x06005BEA RID: 23530 RVA: 0x00141AFC File Offset: 0x0013FCFC
        private static MethodBase GetMethodBase(IConstructionCallMessage msg)
        {
            MethodBase methodBase = msg.MethodBase;

            if (null == methodBase)
            {
                throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Message_MethodMissing"), msg.MethodName, msg.TypeName));
            }
            return(methodBase);
        }
 public void GetPropertiesForNewContext(IConstructionCallMessage ctor)
 {
     if (_contextProperties != null)
     {
         foreach (object prop in _contextProperties)
         {
             ctor.ContextProperties.Add(prop);
         }
     }
 }
Exemple #31
0
        ///
        public override void GetPropertiesForNewContext(IConstructionCallMessage ccm)
        {
            var type = Type.GetType(ccm.TypeName);

            var methodsInfos = type
                               .GetMethods()
                               .Where(x => x.GetCustomAttributes <ActionNameAttribute>().Any());

            ccm.ContextProperties.Add(new CallTracingProperty(callTrace, type, methodsInfos));
        }
Exemple #32
0
        public override IMessage Invoke(IMessage msg)
        {
            if (msg != null)
            {
                if (msg is IConstructionCallMessage)
                {
                    IConstructionCallMessage constructCallMsg = msg as IConstructionCallMessage;
                    //IConstructionReturnMessage constructionReturnMessage = this.InitializeServerObject((IConstructionCallMessage)msg);
                    //RealProxy.SetStubData(this, constructionReturnMessage.ReturnValue);
                    //return constructionReturnMessage;

                    RealProxy defaultProxy = RemotingServices.GetRealProxy(_target);

                    //如果不做下面这一步,_target还是一个没有直正实例化被代理对象的透明代理,
                    //这样的话,会导致没有直正构建对象。
                    defaultProxy.InitializeServerObject(constructCallMsg);

                    //本类是一个RealProxy,它可通过GetTransparentProxy函数得到透明代理
                    return(EnterpriseServicesHelper.CreateConstructionReturnMessage(constructCallMsg, (MarshalByRefObject)GetTransparentProxy()));
                }
                else if (msg is IMethodCallMessage)
                {
                    IMethodCallMessage callMsg = msg as IMethodCallMessage;
                    object[]           args    = callMsg.Args;

                    //System.Windows.Forms.MessageBox.Show(callMsg.MethodBase.ToString());

                    if (callMsg.MethodName.StartsWith("set_") && args.Length == 1)
                    {
                        method.Invoke(_target, new object[] { callMsg.MethodName.Substring(4), args[0] });//对属性进行调用
                    }
                    return(RemotingServices.ExecuteMessage(_target, callMsg));

                    //IMessage message = null;
                    //try
                    //{

                    //    MarshalByRefObject obj = GetUnwrappedServer();
                    //    if (callMsg.MethodName.StartsWith("set_") && args.Length == 1)
                    //    {
                    //        method.Invoke(obj, new object[] { callMsg.MethodName.Substring(4), args[0] });//对属性进行调用
                    //    }

                    //    object o = callMsg.MethodBase.Invoke(obj, args);
                    //    message = new ReturnMessage(o, args, args.Length, callMsg.LogicalCallContext, callMsg);
                    //}
                    //catch (Exception e)
                    //{
                    //    message = new ReturnMessage(e, callMsg);
                    //}
                    //return message;
                }
            }
            return(msg);
        }
 public static IMessage RemoteActivate(IConstructionCallMessage ctorCall)
 {
     try
     {
         return(ctorCall.Activator.Activate(ctorCall));
     }
     catch (Exception ex)
     {
         return(new ReturnMessage(ex, ctorCall));
     }
 }
		public static IMessage RemoteActivate (IConstructionCallMessage ctorCall)
		{
			try 
			{
				return ctorCall.Activator.Activate (ctorCall);
			}
			catch (Exception ex) 
			{
				return new ReturnMessage (ex, ctorCall);
			}		
		}
        //Le runtime .NET interroge pour savoir si le contexte courant est valide.
        //Si cette fonction false, le runtime créé un nouveau contexte et appelle GetPropertiesForNewContext()
        // pour vérifier si le context est valid, on vérifie la présence (et la validité si besoin) d'un propriété
        public override bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg)
        {
            //return false;	// Seulement si vous souhaitez un contexte par instance !
            DataValidationProperty prop = ctx.GetProperty("DataValidation") as DataValidationProperty;

            if (prop != null)           // on a une propriété appelé ValidationData dans le contexte ?
            {
                return(true);           // Oui -> on accepte le contexte
            }
            return(false);              // Non -> on refuse le contexte
        }
        internal static object ConnectIfNecessary(IConstructionCallMessage ctorMsg)
        {
            string text   = (string)ctorMsg.Properties["Connect"];
            object result = null;

            if (text != null)
            {
                result = RemotingServices.Connect(ctorMsg.ActivationType, text);
            }
            return(result);
        }
        internal static object CheckIfConnected(RemotingProxy proxy, IConstructionCallMessage ctorMsg)
        {
            string text   = (string)ctorMsg.Properties["Connect"];
            object result = null;

            if (text != null)
            {
                result = proxy.GetTransparentProxy();
            }
            return(result);
        }
Exemple #38
0
        internal static object ConnectIfNecessary(IConstructionCallMessage ctorMsg)
        {
            string url  = (string)ctorMsg.Properties["Connect"];
            object obj2 = null;

            if (url != null)
            {
                obj2 = RemotingServices.Connect(ctorMsg.ActivationType, url);
            }
            return(obj2);
        }
Exemple #39
0
        public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
        {
            if (ctorMsg == null)
            {
                throw new ArgumentNullException("ctorMsg");
            }

            IContextProperty cachedProperty = new CachedContextProperty();

            ctorMsg.ContextProperties.Add(cachedProperty);
        }
Exemple #40
0
        public override void GetPropertiesForNewContext(IConstructionCallMessage msg)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("msg");
            }

            msg.ContextProperties.Add(new CoreTestProperty<TestTimerAspect>());
            msg.ContextProperties.Add(new CoreTestProperty<TestTransactionAspect>());
            msg.ContextProperties.Add(new CoreTestProperty<ExpectedExceptionMessageAspect>());
        }
Exemple #41
0
        /// <summary>
        ///    Adds the current context property to the IConstructionCallMessage
        /// </summary>
        public virtual void GetPropertiesForNewContext(IConstructionCallMessage msg)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("IConstructionCallMessage");
            }

            IList list = msg.ContextProperties;

            list.Add(this);
        }
        public static IConstructionReturnMessage CreateConstructionReturnMessage(IConstructionCallMessage ctorMsg, MarshalByRefObject retObj)
        {
            IConstructionReturnMessage ctorRetMsg = null;

            // Create the return message
            ctorRetMsg = new ConstructorReturnMessage(retObj, null, 0, null, ctorMsg);

            // NOTE: WE ALLOW ONLY DEFAULT CTORs on SERVICEDCOMPONENTS

            return(ctorRetMsg);
        }
Exemple #43
0
 public bool IsContextOK(Context ctx, IConstructionCallMessage msg)
 {
     //
     //  Beginn Aenderung Test
     //
     Console.WriteLine("\n\t****C#: bool IsContextOK (Context ctx, IConstructionCallMessage msg) ****\n");
     //
     //  Ende Aenderung Test
     //
     return(false);
 }
Exemple #44
0
        internal static object CheckIfConnected(RemotingProxy proxy, IConstructionCallMessage ctorMsg)
        {
            string str = (string)ctorMsg.Properties["Connect"];
            object transparentProxy = null;

            if (str != null)
            {
                transparentProxy = proxy.GetTransparentProxy();
            }
            return(transparentProxy);
        }
        public static IConstructionReturnMessage CreateConstructionReturnMessage(IConstructionCallMessage ctorMsg, MarshalByRefObject retObj) 
        {
            IConstructionReturnMessage ctorRetMsg = null; 

            // Create the return message
            ctorRetMsg = new ConstructorReturnMessage(retObj, null, 0, null, ctorMsg);
 
            // NOTE: WE ALLOW ONLY DEFAULT CTORs on SERVICEDCOMPONENTS
 
            return ctorRetMsg; 
        }
		public override bool IsContextOK (Context ctx, IConstructionCallMessage msg)
		{
			SyncContext sctx = SyncContext.GetContext ();
			if (sctx == null || (sctx.GetType() != contextType)) {
				syncContext = (SyncContext) Activator.CreateInstance (contextType);
				return false;
			}
			else {
				syncContext = sctx;
				return true;
			}
		}
        //Le runtime .NET interroge l'attribut pour savoir si le contexte courant est valide.
        //Si cette fonction renvoi false, le runtime créé un nouveau contexte et appelle GetPropertiesForNewContext()
        // pour vérifier si le context est valid, on vérifie la présence (et la validité si besoin) d'une propriété
        public override bool IsContextOK(Context ctx,IConstructionCallMessage ctorMsg)
        {
            //le return false permet de forcer systématiquement un nouveau contexte pour chaqueinstance
            // utilise si une instance d'un type créé des instance de ce meme type : vous pouvez intercepter
            // les appels entre instance d'un meme type ( car il y aura changement de contexte )
            //return false;

            InterceptionAppelProperty prop=ctx.GetProperty("InterceptionAppelProperty") as InterceptionAppelProperty;
            if (prop!=null)	// on a une propriété appelé InterceptionAppelProperty dans le contexte ?
                return true;	// Oui -> on accepte le contexte

            return false;	// Non -> on refuse le contexte
        }
Exemple #48
0
		public IConstructionReturnMessage Activate (IConstructionCallMessage msg)
		{
			if (!RemotingConfiguration.IsActivationAllowed (msg.ActivationType))
				throw new RemotingException ("The type " + msg.ActivationTypeName + " is not allowed to be client activated");

			object[] activationAttributes = new object[] { new RemoteActivationAttribute (msg.ContextProperties) };
			MarshalByRefObject newObject = (MarshalByRefObject) Activator.CreateInstance (msg.ActivationType, msg.Args, activationAttributes);

			// The activator must return a ConstructionResponse with an ObjRef as return value.
			// It avoids the automatic creation of a proxy in the client.

			ObjRef objref = RemotingServices.Marshal (newObject);
			return new ConstructionResponse (objref, null, msg);
		}
 internal static IConstructionReturnMessage DoRemoteActivation(IConstructionCallMessage ctorMsg)
 {
     IActivator activator = null;
     string url = (string) ctorMsg.Properties["Remote"];
     try
     {
         activator = (IActivator) RemotingServices.Connect(typeof(IActivator), url);
     }
     catch (Exception exception)
     {
         throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Activation_ConnectFailed"), new object[] { exception }));
     }
     ctorMsg.Properties.Remove("Remote");
     return activator.Activate(ctorMsg);
 }
 /// <summary>
 /// Проверка типа подключения при создании объекта
 /// </summary>
 /// <param name="msg">Дескриптор конструктора объекта</param>
 private void ConnectionTypeValidation(IConstructionCallMessage msg)
 {
     if (msg.ArgCount > 0)
     {
         foreach (var arg in msg.Args)
         {
             if (arg is IDbConnection)
             {
                 Type type = arg.GetType();
                 Require.That(connectionType.IsAssignableFrom(type),
                     "Данный провайдер использует подключения типа [{0}]. При инициализации провайдера было указано подключение типа [{1}]", connectionType.FullName, type.FullName);
             }
         }
     }
 }
 public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg)
 {
     if ((ctorMsg == null) || RemotingServices.IsTransparentProxy(ctorMsg))
     {
         throw new ArgumentNullException("ctorMsg");
     }
     ctorMsg.Properties["Permission"] = "allowed";
     if (!RemotingConfigHandler.IsActivationAllowed(ctorMsg.ActivationTypeName))
     {
         throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Activation_PermissionDenied"), new object[] { ctorMsg.ActivationTypeName }));
     }
     if (ctorMsg.ActivationType == null)
     {
         throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_BadType"), new object[] { ctorMsg.ActivationTypeName }));
     }
     return ActivationServices.GetActivator().Activate(ctorMsg);
 }
		public IConstructionReturnMessage Activate (IConstructionCallMessage ctorCall)
		{
			ServerIdentity identity = RemotingServices.CreateContextBoundObjectIdentity (ctorCall.ActivationType);
			RemotingServices.SetMessageTargetIdentity (ctorCall, identity);

			ConstructionCall call = ctorCall as ConstructionCall;
			if (call == null || !call.IsContextOk)
			{
				identity.Context = Context.CreateNewContext (ctorCall);
				Context oldContext = Context.SwitchToContext (identity.Context);

				try
				{
					return m_NextActivator.Activate (ctorCall);
				}
				finally
				{
					Context.SwitchToContext (oldContext);
				}
			}
			else
				return m_NextActivator.Activate (ctorCall);
		}
 public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg)
 {
     if (ctorMsg == null)
     {
         throw new ArgumentNullException("ctorMsg");
     }
     if (ctorMsg.Properties.Contains("Remote"))
     {
         return DoRemoteActivation(ctorMsg);
     }
     if (!ctorMsg.Properties.Contains("Permission"))
     {
         return ctorMsg.Activator.Activate(ctorMsg);
     }
     Type activationType = ctorMsg.ActivationType;
     object[] activationAttributes = null;
     if (activationType.IsContextful)
     {
         IList contextProperties = ctorMsg.ContextProperties;
         if ((contextProperties != null) && (contextProperties.Count > 0))
         {
             RemotePropertyHolderAttribute attribute = new RemotePropertyHolderAttribute(contextProperties);
             activationAttributes = new object[] { attribute };
         }
     }
     RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(GetMethodBase(ctorMsg));
     object[] args = Message.CoerceArgs(ctorMsg, reflectionCachedData.Parameters);
     object obj2 = Activator.CreateInstance(activationType, args, activationAttributes);
     if (RemotingServices.IsClientProxy(obj2))
     {
         RedirectionProxy proxy = new RedirectionProxy((MarshalByRefObject) obj2, activationType);
         RemotingServices.MarshalInternal(proxy, null, activationType);
         obj2 = proxy;
     }
     return ActivationServices.SetupConstructionReply(obj2, ctorMsg, null);
 }
Exemple #54
0
 public override void GetPropertiesForNewContext(IConstructionCallMessage ccm)
 {
     ccm.ContextProperties.Add(new TracingProperty());
 }
Exemple #55
0
		internal static Context CreateNewContext (IConstructionCallMessage msg)
		{
			// Create the new context

			Context newContext = new Context();

			foreach (IContextProperty prop in msg.ContextProperties)
			{
				if (newContext.GetProperty (prop.Name) == null)
					newContext.SetProperty (prop);
			}
			newContext.Freeze();


			// Ask each context property whether the new context is OK

			foreach (IContextProperty prop in msg.ContextProperties)
				if (!prop.IsNewContextOK (newContext)) 
					throw new RemotingException("A context property did not approve the candidate context for activating the object");

			return newContext;
		}
Exemple #56
0
		public IConstructionReturnMessage InitializeServerObject(IConstructionCallMessage ctorMsg)
		{
			throw new NotImplementedException();
		}
 public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg)
 {
     ctorMsg.Activator = ctorMsg.Activator.NextActivator;
     return ActivationServices.DoServerContextActivation(ctorMsg);
 }
Exemple #58
0
 public override bool IsContextOK(Context ctx, IConstructionCallMessage ctorMsg)
 {
     return false;
 }
Exemple #59
0
 public override void GetPropertiesForNewContext(IConstructionCallMessage ctor)
 {
     if (AOPConfig.Enabled)
         ctor.ContextProperties.Add(new AOPProperty());
 }
        public override void GetPropertiesForNewContext(IConstructionCallMessage ctorMsg)
        {
            if ( (_flavor==NOT_SUPPORTED) || (_flavor==SUPPORTED) || (null == ctorMsg) )
            {
                return ;
            }

            if (_cliCtxAttr != null)
            {
                Contract.Assert(_flavor == REQUIRED,"Use cli-ctx property only for the REQUIRED flavor");
                ctorMsg.ContextProperties.Add((IContextProperty)_cliCtxAttr);
                _cliCtxAttr = null;
            }
            else
            {
                ctorMsg.ContextProperties.Add((IContextProperty)this);
            }
        }