コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the OrderedObservableCollection using an IComparer implementation.
 /// </summary>
 /// <param name="comparer">IComparer implementation used for the item comparisons during ordering</param>
 /// <param name="options">Options that control the behavior of the collection</param>
 public OrderedObservableCollection(IComparer <T> comparer, OrderedObservableCollectionOptions options)
 {
     if (comparer == null)
     {
         throw new ArgumentNullException("comparer");
     }
     _comparer = comparer;
     _options  = options ?? new OrderedObservableCollectionOptions();
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the OrderedObservableCollection class using a Comparison delegate for
 /// the comparison logic.
 /// </summary>
 /// <param name="comparison">The comparison delegate used for the item comparisons during ordering</param>
 /// <param name="options">Options that control the behavior of the collection</param>
 public OrderedObservableCollection(Comparison <T> comparison, OrderedObservableCollectionOptions options)
 {
     if (comparison == null)
     {
         throw new ArgumentNullException("comparison");
     }
     _comparer = new ComparisonComparer <T>(comparison);
     _options  = options ?? new OrderedObservableCollectionOptions();
 }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the OrderedObservableCollection
        /// </summary>
        /// <param name="options">Options that control the behavior of the collection</param>
        public OrderedObservableCollection(OrderedObservableCollectionOptions options)
        {
            Type comparableType = typeof(IComparable <>).MakeGenericType(typeof(T));

            if (!comparableType.IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException("Generic type should implement IComparable<>");
            }
            _comparer = new ComparableComparer <T>();
            _options  = options ?? new OrderedObservableCollectionOptions();
        }