using System; using System.Collections.Generic; using System.Collections.ObjectModel; namespace Neo.Afx.Collections { /// /// A collection of int values that map to year values. /// public class YearCollection : ReadOnlyCollection> { /// /// Initializes a new instance of the class. /// public YearCollection() : this(-5, 10) { } /// /// Initializes a new instance of the class. /// /// The number to add to the current year to get the min value. /// The number to add to the current year to get the max value. public YearCollection(int minusCurrent, int plusCurrent) : base(CreateList(minusCurrent, plusCurrent)) { } static List> CreateList(int beforeCurrent, int afterCurrent) { var min = DateTime.Today.Year + beforeCurrent; var max = DateTime.Today.Year + afterCurrent; var options = new List>(); for(var i = min; i <= max; i++) { options.Add(new KeyValuePair(i, i.ToString())); } return options; } } }