private static GenericKeyedCollection <Type, RuleInfo> InitializeRulesMap()
        {
            var map = new GenericKeyedCollection <Type, RuleInfo>(x => x.RuleType);

            foreach (RuleInfo rule in RulesReader.ReadRules(typeof(AsyncRules)))
            {
                map.Add(rule);
            }

            return(map);
        }
Example #2
0
        public void SimpleContstructor()
        {
            var keyedCollection = new GenericKeyedCollection <string, CollectionItem>(item => { return(item.Key); })
            {
                new CollectionItem {
                    Key = "A", Value = "Test key A"
                },
                new CollectionItem {
                    Key = "B", Value = "Test key B"
                }
            };

            var collectionItem = keyedCollection["A"];

            Assert.IsNotNull(collectionItem);
            Assert.IsNotNull(collectionItem.Key);
            Assert.AreEqual("A", collectionItem.Key);
            Assert.IsNotNull(collectionItem.Value);
            Assert.AreEqual("Test key A", collectionItem.Value);
        }
		/// <summary>Creates a <see cref="StartingLineup"/> for each day in the date range.</summary>
		/// <param name="startDate">The first day that starting lineups should be created for.</param>
		/// <param name="endDate">The last day that starting lineups should be created for.</param>
		/// <param name="players">The players available to fill starting lineup spots.</param>
		/// <returns>Returns a <see cref="StartingLineup"/> for each day in the date range.</returns>
		public KeyedCollection<DateTime, StartingLineup> CreateStartingLineups(DateTime startDate, DateTime endDate, IEnumerable<Player> players)
		{
			GenericKeyedCollection<DateTime, StartingLineup> startinglineups = new GenericKeyedCollection<DateTime, StartingLineup>(startingLineup => startingLineup.Date.Date);

			if (startDate > endDate) { throw new ArgumentException("End date cannot be before start date.", "endDate"); }
			for (DateTime date = startDate; date <= endDate; date = date.AddDays(1))
			{
				startinglineups.Add(this.CreateStartingLineup(date, players));
			}

			return startinglineups;
		}