예제 #1
0
        protected override Channel <T> Visitor <T>(ChannelAdapter <T> channel)
        {
            Channel <T> output = channel.Output;

            if (_channels.Contains(output))
            {
                var shunt = new ShuntChannel <T>();
                channel.ChangeOutputChannel(output, shunt);

                _channels.Remove(output);
            }

            Channel <T> newOutput = Visit(output);

            if (newOutput != output)
            {
                channel.ChangeOutputChannel(output, newOutput);
            }

            return(channel);
        }
예제 #2
0
        protected override UntypedChannel Visitor(ChannelAdapter channel)
        {
            channel.ChangeOutputChannel(output =>
            {
                UntypedChannel replacement = Visit(output);

                if (_channels.Contains(output))
                {
                    replacement = null;

                    _channels.Remove(output);
                }

                return(replacement ?? new ShuntChannel());
            });

            return(channel);
        }
예제 #3
0
        protected override UntypedChannel Visitor(ChannelAdapter channel)
        {
            UntypedChannel original = channel.Output;

            UntypedChannel replacement = Visit(original);

            if (!_added)
            {
                if (replacement.GetType() == typeof(ShuntChannel))
                {
                    replacement = new BroadcastChannel(new[] { _newChannel });
                    _added      = true;
                }
            }

            if (original != replacement)
            {
                channel.ChangeOutputChannel(original, replacement);
            }

            return(channel);
        }
예제 #4
0
        protected override Channel <T> Visitor <T>(ChannelAdapter <T> channel)
        {
            channel.ChangeOutputChannel(output =>
            {
                Channel <T> replacement = output;

                if (_channels.Contains(output))
                {
                    replacement = new ShuntChannel <T>();

                    _channels.Remove(output);
                }

                Channel <T> newOutput = Visit(output);
                if (newOutput != output)
                {
                    replacement = newOutput;
                }

                return(replacement);
            });

            return(channel);
        }
예제 #5
0
        protected override UntypedChannel Visitor(ChannelAdapter channel)
        {
            bool wasAdded = _added;

            channel.ChangeOutputChannel(original =>
            {
                _added = wasAdded;

                UntypedChannel replacement = Visit(original);

                if (!_added)
                {
                    if (replacement.GetType() == typeof(ShuntChannel))
                    {
                        replacement = new BroadcastChannel(new[] { _newChannel });
                        _added      = true;
                    }
                }

                return(replacement);
            });

            return(channel);
        }
예제 #6
0
        protected override UntypedChannel Visitor(ChannelAdapter channel)
        {
            UntypedChannel original = channel.Output;

            UntypedChannel replacement = Visit(original);

            if (_channels.Contains(replacement))
            {
                _channels.Remove(replacement);
                replacement = null;
            }

            if (replacement == null)
            {
                replacement = new ShuntChannel();
            }

            if (replacement != original)
            {
                channel.ChangeOutputChannel(original, replacement);
            }

            return(channel);
        }
예제 #7
0
        protected override UntypedChannel Visitor(ChannelAdapter channel)
        {
            UntypedChannel original = channel.Output;

            UntypedChannel replacement = Visit(original);

            if (!_added)
            {
                if (replacement.GetType() == typeof(ShuntChannel))
                {
                    replacement = new BroadcastChannel(new[] {_newChannel});
                    _added = true;
                }
            }

            if (original != replacement)
                channel.ChangeOutputChannel(original, replacement);

            return channel;
        }
예제 #8
0
        protected override UntypedChannel Visitor(ChannelAdapter channel)
        {
            bool wasAdded = _added;

            channel.ChangeOutputChannel(original =>
                {
                    _added = wasAdded;

                    UntypedChannel replacement = Visit(original);

                    if (!_added)
                    {
                        if (replacement.GetType() == typeof(ShuntChannel))
                        {
                            replacement = new BroadcastChannel(new[] { _newChannel });
                            _added = true;
                        }
                    }

                    return replacement;
                });

            return channel;
        }