コード例 #1
0
        void ValidateBinding(IMessageSink <InMemoryTransportMessage> destination, IInMemoryExchange sourceExchange)
        {
            try
            {
                var graph = new DependencyGraph <IMessageSink <InMemoryTransportMessage> >(_exchanges.Count + 1);
                foreach (var exchange in _exchanges.Values)
                {
                    foreach (IMessageSink <InMemoryTransportMessage> sink in exchange.Sinks)
                    {
                        graph.Add(sink, exchange);
                    }
                }

                graph.Add(destination, sourceExchange);

                graph.EnsureGraphIsAcyclic();
            }
            catch (Exception exception)
            {
                throw new InvalidOperationException($"The exchange binding would create a cycle in the messaging fabric.", exception);
            }
        }