Beispiel #1
0
        public IReadOnlyCollection <IEventLoggingStrategy <TEvent> > Get <TEvent>(IReadOnlyCollection <TEvent> events)
        {
            var messageFlow = events.Cast <FlowEvent>().Select(x => x.Flow).ToHashSet().Single();

            IEventLoggingStrategy <TEvent> strategy;

            var vrFactsFlows = new IEquatable <IMessageFlow>[]
            {
                ErmFactsFlow.Instance,
                AmsFactsFlow.Instance,
                RulesetFactsFlow.Instance
            };

            if (vrFactsFlows.Contains(messageFlow))
            {
                strategy = ResolveServiceBusStrategy <TEvent>(AggregatesFlow.Instance);
            }
            else if (Equals(messageFlow, AggregatesFlow.Instance))
            {
                strategy = ResolveServiceBusStrategy <TEvent>(MessagesFlow.Instance);
            }
            else
            {
                throw new ArgumentOutOfRangeException(nameof(messageFlow), messageFlow, "Unexpected flow");
            }

            return(new [] { strategy });
        }