private void InitializeWithFormatters(IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider) { ClientSinkProvider = clientSinkProvider = clientSinkProvider ?? new BinaryClientFormatterSinkProvider(); serverSinkProvider = serverSinkProvider ?? new BinaryServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full }; // add our client sink provider to the end of ClientSinkProvider chain while (clientSinkProvider.Next != null) { clientSinkProvider = clientSinkProvider.Next; } clientSinkProvider.Next = new NullClientChannelSink.Provider(); // collect channel data var provider = serverSinkProvider; while (provider.Next != null) { provider.GetChannelData(ChannelDataStore); provider = provider.Next; } // create server sink chain var nextSink = ChannelServices.CreateServerChannelSinkChain(serverSinkProvider, this); ServerSink = new NullServerChannelSink(nextSink); }
/// <summary> /// Ininitializes a new instance of the <see cref="NullChannel"/> class. /// </summary> /// <param name="channelName">Channel name.</param> /// <param name="clientSinkProvider">The client sink provider.</param> /// <param name="serverSinkProvider">The server sink provider.</param> public NullChannel(string channelName = "NullChannel", IClientChannelSinkProvider clientSinkProvider = null, IServerChannelSinkProvider serverSinkProvider = null) { ChannelName = channelName; ChannelDataStore = new ChannelDataStore(new[] { "null://" + channelName }); // standard mode: message serialization must be enabled if (clientSinkProvider != null || serverSinkProvider != null) { InitializeWithFormatters(clientSinkProvider, serverSinkProvider); } else { // fast mode (no additional sinks specified) — bypass serialization ClientSinkProvider = new NullClientChannelSink.Provider(); ServerSink = new NullServerChannelSink(null); } // start listening for messages StartListening(null); }
private void InitializeWithFormatters(IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider) { ClientSinkProvider = clientSinkProvider = clientSinkProvider ?? new BinaryClientFormatterSinkProvider(); serverSinkProvider = serverSinkProvider ?? new BinaryServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full }; // add our client sink provider to the end of ClientSinkProvider chain while (clientSinkProvider.Next != null) clientSinkProvider = clientSinkProvider.Next; clientSinkProvider.Next = new NullClientChannelSink.Provider(); // collect channel data var provider = serverSinkProvider; while (provider.Next != null) { provider.GetChannelData(ChannelDataStore); provider = provider.Next; } // create server sink chain var nextSink = ChannelServices.CreateServerChannelSinkChain(serverSinkProvider, this); ServerSink = new NullServerChannelSink(nextSink); }