internal virtual IMessageSink GetServerContextChain()
{
if (_serverContextChain == null)
{
// a bare chain would have just this one sink.
IMessageSink newServerContextChain = ServerContextTerminatorSink.MessageSink;
// now loop over properties to add some real sinks.
Object prop = null;
int iSink = _numCtxProps;
while (iSink-- > 0)
{
// see if this property wants to contribute a ServerContextSink
// we have to start chaining in the reverse order
prop = _ctxProps[iSink];
IContributeServerContextSink sink = prop as IContributeServerContextSink;
if (null != sink )
{
// yes, chain the sink ahead of the chain of sinks constructed so far.
newServerContextChain = sink.GetServerContextSink( newServerContextChain);
if (newServerContextChain == null)
{
throw new RemotingException(
Environment.GetResourceString(
"Remoting_Contexts_BadProperty"));
}
}
}
lock (this)
{
if (_serverContextChain == null)
{
_serverContextChain = newServerContextChain;
}
}
}
return _serverContextChain;
}