コード例 #1
0
ファイル: Change.cs プロジェクト: mgnslndh/DynamicData
        /// <summary>
        /// Construtor for ChangeReason.Move
        /// </summary>
        /// <param name="current">The current.</param>
        /// <param name="currentIndex">The CurrentIndex.</param>
        /// <param name="previousIndex">CurrentIndex of the previous.</param>
        /// <exception cref="System.ArgumentException">
        /// CurrentIndex must be greater than or equal to zero
        /// or
        /// PreviousIndex must be greater than or equal to zero
        /// </exception>
        public Change(T current, int currentIndex, int previousIndex)
        {
            if (currentIndex < 0)
                throw new ArgumentException("CurrentIndex must be greater than or equal to zero");

            if (previousIndex < 0)
                throw new ArgumentException("PreviousIndex must be greater than or equal to zero");

            Reason = ListChangeReason.Moved;
            Item = new ItemChange<T>(Reason, current, Optional.None<T>(), currentIndex, previousIndex);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Change{TObject, TKey}" /> struct.
 /// </summary>
 /// <param name="reason">The reason.</param>
 /// <param name="current">The current.</param>
 /// <param name="previous">The previous.</param>
 /// <param name="currentIndex">Value of the current.</param>
 /// <param name="previousIndex">Value of the previous.</param>
 /// <exception cref="ArgumentException">
 /// For ChangeReason.Add, a previous value cannot be specified
 /// or
 /// For ChangeReason.Change, must supply previous value
 /// </exception>
 /// <exception cref="System.ArgumentException">For ChangeReason.Add, a previous value cannot be specified
 /// or
 /// For ChangeReason.Change, must supply previous value</exception>
 public Change(ListChangeReason reason, T current, Optional <T> previous, int currentIndex = -1, int previousIndex = -1)
 {
     if (reason == ListChangeReason.Add && previous.HasValue)
     {
         throw new ArgumentException("For ChangeReason.Add, a previous value cannot be specified");
     }
     if (reason == ListChangeReason.Replace && !previous.HasValue)
     {
         throw new ArgumentException("For ChangeReason.Change, must supply previous value");
     }
     Reason = reason;
     Item   = new ItemChange <T>(Reason, current, previous, currentIndex, previousIndex);
 }
コード例 #3
0
 /// <summary>
 ///  Determines whether the specified object, is equal to this instance.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns></returns>
 public bool Equals(ItemChange <T> other)
 {
     return(EqualityComparer <T> .Default.Equals(Current, other.Current) && CurrentIndex == other.CurrentIndex && Previous.Equals(other.Previous) && PreviousIndex == other.PreviousIndex);
 }