Freeze() приватный Метод

private Freeze ( ) : void
Результат void
Пример #1
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);
        }
        public ProviderValidationProxy(Type type, Type connectionType, bool schemaNameSupported)
            : base(type)
        {
            context = new Context();
            context.Freeze();

            this.connectionType = connectionType;
            this.schemaNameSupported = schemaNameSupported;
        }
Пример #3
0
        internal static Context CreateNewContext(IConstructionCallMessage msg)
        {
            Context context = new Context();

            foreach (object obj in msg.ContextProperties)
            {
                IContextProperty contextProperty = (IContextProperty)obj;
                if (context.GetProperty(contextProperty.Name) == null)
                {
                    context.SetProperty(contextProperty);
                }
            }
            context.Freeze();
            foreach (object obj2 in msg.ContextProperties)
            {
                IContextProperty contextProperty2 = (IContextProperty)obj2;
                if (!contextProperty2.IsNewContextOK(context))
                {
                    throw new RemotingException("A context property did not approve the candidate context for activating the object");
                }
            }
            return(context);
        }
Пример #4
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;
		}
Пример #5
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static IConstructionReturnMessage DoCrossContextActivation(
            IConstructionCallMessage reqMsg)
        {           
            bool bCtxBound = reqMsg.ActivationType.IsContextful;
            Context serverContext = null;
            
            if (bCtxBound)
            {
                // If the type is context bound, we need to create 
                // the appropriate context and activate the object inside
                // it.
                // <

                // Create a new Context
                serverContext = new Context();              

                // <



                
                ArrayList list = (ArrayList) reqMsg.ContextProperties;
                RuntimeAssembly asm = null;
                for (int i=0; i<list.Count; i++)
                {
                    IContextProperty prop = list[i] as IContextProperty;
                    if (null == prop)
                    {
                        throw new RemotingException(
                            Environment.GetResourceString(
                                "Remoting_Activation_BadAttribute"));
                    }
                    asm = (RuntimeAssembly)prop.GetType().Assembly;
                    // Make a security check to ensure that the context property
                    // is from a trusted assembly!
                    CheckForInfrastructurePermission(asm);

                    // This ensures that we don't try to add duplicate
                    // attributes (eg. type attributes common on both client
                    // and server end)
                    if (serverContext.GetProperty(prop.Name) == null)
                    {
                        serverContext.SetProperty(prop);
                    }
                }
                // No more property changes to the server context from here.
                serverContext.Freeze();

                // (This seems like an overkill but that is how it is spec-ed)
                // Ask each of the properties in the context we formed from
                // if it is happy with the current context.
                for (int i=0; i<list.Count;i++)
                {
                    if (!((IContextProperty)list[i]).IsNewContextOK(
                        serverContext))
                    {
                        throw new RemotingException(
                            Environment.GetResourceString(
                                "Remoting_Activation_PropertyUnhappy"));
                    }
                }
            }


            IConstructionReturnMessage  replyMsg;

            InternalCrossContextDelegate xctxDel = 
                new InternalCrossContextDelegate(DoCrossContextActivationCallback);

            Object[] args = new Object[] { reqMsg };
            
            if (bCtxBound)
            {
                replyMsg = Thread.CurrentThread.InternalCrossContextCallback(
                    serverContext, xctxDel, args) as IConstructionReturnMessage;
            }
            else
            {
                replyMsg = xctxDel(args) as IConstructionReturnMessage;
            }

            return replyMsg;
        }
Пример #6
0
        // This function is called by ActivationServices in case
        // the activation needs to be within the same appdomain. These
        // are only for ContextBound types.
        // It is also called to do satisfy remote incoming requests from
        // the activation services. These could be for both ContextBound
        // and MarshalByRef types.
        internal static IConstructionReturnMessage DoCrossContextActivation(
            IConstructionCallMessage reqMsg)
        {           
            bool bCtxBound = reqMsg.ActivationType.IsContextful;
            ContextTransitionFrame frame = new ContextTransitionFrame();
            if (bCtxBound)
            {
                // If the type is context bound, we need to create 
                // the appropriate context and activate the object inside
                // it.

                // Create a new Context
                Context serverContext = new Context();              

                
                ArrayList list = (ArrayList) reqMsg.ContextProperties;
                Assembly asm = null;
                for (int i=0; i<list.Count; i++)
                {
                    IContextProperty prop = list[i] as IContextProperty;
                    if (null == prop)
                    {
                        throw new RemotingException(
                            Environment.GetResourceString(
                                "Remoting_Activation_BadAttribute"));
                    }
                    asm = prop.GetType().Assembly; 
                    // Make a security check to ensure that the context property
                    // is from a trusted assembly!
		    CheckForInfrastructurePermission(asm);

                    // This ensures that we don't try to add duplicate
                    // attributes (eg. type attributes common on both client
                    // and server end)
                    if (serverContext.GetProperty(prop.Name) == null)
                    {
                        serverContext.SetProperty(prop);
                    }
                }
                // No more property changes to the server context from here.
                serverContext.Freeze();

                // (This seems like an overkill but that is how it is spec-ed)
                // Ask each of the properties in the context we formed from
                // if it is happy with the current context.
                for (int i=0; i<list.Count;i++)
                {
                    if (!((IContextProperty)list[i]).IsNewContextOK(
                        serverContext))
                    {
                        throw new RemotingException(
                            Environment.GetResourceString(
                                "Remoting_Activation_PropertyUnhappy"));
                    }
                }

                // Change to server context
                Thread.CurrentThread.EnterContext(serverContext, ref frame);
            }

            // call the first sink in the server context chain
            IMethodReturnMessage retMsg =  (IMethodReturnMessage) 
                    Thread.CurrentContext.GetServerContextChain().SyncProcessMessage(reqMsg);

            // The return message may not be of type
            // IConstructionReturnMessage if an exception happens
            // in the sink chains.
            Exception e = null;
            IConstructionReturnMessage replyMsg = retMsg as IConstructionReturnMessage;
            if (null == replyMsg)
            {
                if (retMsg != null)
                {
                    e = retMsg.Exception;
                }
                else
                {
                    e = new RemotingException(
                            Environment.GetResourceString(
                                "Remoting_Activation_Failed"));

                }
                replyMsg = new ConstructorReturnMessage(e,null); 
                // We have created our own message ... transfer the callcontext
                // from the request message.
                ((ConstructorReturnMessage)replyMsg).SetLogicalCallContext(
                        (LogicalCallContext)
                        reqMsg.Properties[Message.CallContextKey]);
            }

            if (bCtxBound)
            {
                Thread.CurrentThread.ReturnToContext(ref frame);
            }

            return replyMsg;
        }
 internal static IConstructionReturnMessage DoCrossContextActivation(IConstructionCallMessage reqMsg)
 {
     bool isContextful = reqMsg.ActivationType.IsContextful;
     Context newCtx = null;
     if (isContextful)
     {
         newCtx = new Context();
         ArrayList contextProperties = (ArrayList) reqMsg.ContextProperties;
         RuntimeAssembly asm = null;
         for (int i = 0; i < contextProperties.Count; i++)
         {
             IContextProperty prop = contextProperties[i] as IContextProperty;
             if (prop == null)
             {
                 throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute"));
             }
             asm = (RuntimeAssembly) prop.GetType().Assembly;
             CheckForInfrastructurePermission(asm);
             if (newCtx.GetProperty(prop.Name) == null)
             {
                 newCtx.SetProperty(prop);
             }
         }
         newCtx.Freeze();
         for (int j = 0; j < contextProperties.Count; j++)
         {
             if (!((IContextProperty) contextProperties[j]).IsNewContextOK(newCtx))
             {
                 throw new RemotingException(Environment.GetResourceString("Remoting_Activation_PropertyUnhappy"));
             }
         }
     }
     InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(ActivationServices.DoCrossContextActivationCallback);
     object[] args = new object[] { reqMsg };
     if (isContextful)
     {
         return (Thread.CurrentThread.InternalCrossContextCallback(newCtx, ftnToCall, args) as IConstructionReturnMessage);
     }
     return (ftnToCall(args) as IConstructionReturnMessage);
 }