System.Runtime.Remoting.Contexts.Context.CreateEnvoyChain C# (CSharp) Method

CreateEnvoyChain() private method

private CreateEnvoyChain ( MarshalByRefObject objectOrProxy ) : IMessageSink
objectOrProxy MarshalByRefObject
return IMessageSink
        internal virtual IMessageSink CreateEnvoyChain(MarshalByRefObject objectOrProxy)
        {
            // a bare chain would just be the dispatcher sink
            IMessageSink envoyChain = EnvoyTerminatorSink.MessageSink;
            
            // now loop over properties to add some real sinks.
            // Note: the sinks in the envoy chain should be in mirror image
            // order relative to sinks on the server side
            Object prop = null;
            int iSink = 0;
            
            MarshalByRefObject exposedObj = objectOrProxy;
        
            while (iSink < _numCtxProps) 
            {
                // see if this property wants to contribute a ClientContextSink
                // we have to start chaining in the reverse order
                prop = _ctxProps[iSink];
                IContributeEnvoySink sink = prop as IContributeEnvoySink; 
                if (null != sink)
                {
                    // yes, chain the sink ahead of the chain of sinks constructed so far.
                    envoyChain = sink.GetEnvoySink(exposedObj, envoyChain);
                    if (envoyChain == null)
                    {
                        throw new RemotingException( 
                            Environment.GetResourceString(
                                "Remoting_Contexts_BadProperty"));
                    }
                }
                iSink++;
            }
            return envoyChain;
        }