コード例 #1
0
        public IDestination SelectNextDestination(params IDestination[] receivers)
        {
            receivers = receivers.Where(d => d != null)
                        .ToArray();
            if (receivers.Any())
            {
                var indexes = new List <int>();
                foreach (var receiver in receivers)
                {
                    var index = destinations.IndexOf(receiver);
                    if (index < 0)
                    {
                        logger.Warn($"Destination [{receiver}] is not found in {GetType().Name}");
                        return(receiver);
                    }
                    indexes.Add(index);
                }

                var nextDestinationIndex = indexes.Min();
                var destination          = destinations.RemoveAt(nextDestinationIndex);
                destinations.InsertLast(destination);

                return(destination);
            }

            return(null);
        }