Example #1
0
 public ListChangeEventArgs(ListChangeAction action)
 {
     this.NewStartingIndex = -1;
     this.OldStartingIndex = -1;
     (action == ListChangeAction.Reset).AssertTrue();
     this.InitializeAdd(action, null, -1);
 }
Example #2
0
 public ListChangeEventArgs(ListChangeAction action)
 {
     this.NewStartingIndex = -1;
     this.OldStartingIndex = -1;
     (action == ListChangeAction.Reset).AssertTrue();
     this.InitializeAdd(action, null, -1);
 }
Example #3
0
        public ListChangeEventArgs(ListChangeAction action, object newItem, object oldItem, int index)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            (action == ListChangeAction.Replace).AssertTrue();
            this.InitializeMoveOrReplace(action, new object[] { newItem }, new object[] { oldItem }, index, index);
        }
Example #4
0
        public ListChangeEventArgs(ListChangeAction action, IList changedItems, int index, int oldIndex)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            (action == ListChangeAction.Move).AssertTrue();
            (index >= 0).AssertTrue();
            this.InitializeMoveOrReplace(action, changedItems, changedItems, index, oldIndex);
        }
Example #5
0
        public ListChangeEventArgs(ListChangeAction action, IList newItems, IList oldItems, int startingIndex)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            (action == ListChangeAction.Replace).AssertTrue();
            (newItems != null && oldItems != null).AssertTrue();
            this.InitializeMoveOrReplace(action, newItems, oldItems, startingIndex, startingIndex);
        }
Example #6
0
        /// <summary>
        /// Applies the stack to the provided list
        /// </summary>
        /// <param name="list">The list to be modified</param>
        /// <param name="addUnique">True to use AddUnique, false to use Add</param>
        public void ApplyStackToList(IList <ElementType> list, bool addUnique = false)
        {
            ListChangeAction listAddAction = list.Add;

            if (addUnique)
            {
                listAddAction = (x) => list.AddUnique(x);
            }

            ApplyStack(listAddAction, (x) => list.Remove(x));
        }
Example #7
0
        public ListChangeEventArgs(ListChangeAction action, object changedItem, int index, int oldIndex)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            (action == ListChangeAction.Move).AssertTrue();
            (index >= 0).AssertTrue();

            var newItems = new object[] { changedItem };

            this.InitializeMoveOrReplace(action, newItems, newItems, index, oldIndex);
        }
Example #8
0
 private void InitializeAddOrRemove(ListChangeAction action, IList changedItems, int startingIndex)
 {
     if (action == ListChangeAction.Add)
     {
         this.InitializeAdd(action, changedItems, startingIndex);
     }
     else if (action == ListChangeAction.Remove)
     {
         this.InitializeRemove(action, changedItems, startingIndex);
     }
     else
     {
         AssertionHelper.Fail();
     }
 }
Example #9
0
        public ListChangeEventArgs(ListChangeAction action, object changedItem)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            ((action == ListChangeAction.Add) ||
             (action == ListChangeAction.Remove) ||
             (action == ListChangeAction.Reset)).AssertTrue();

            if (action == ListChangeAction.Reset)
            {
                changedItem.AssertNull();
                this.InitializeAdd(action, null, -1);
            }
            else
            {
                this.InitializeAddOrRemove(action, new object[] { changedItem }, -1);
            }
        }
Example #10
0
        public ListChangeEventArgs(ListChangeAction action, object changedItem)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            ((action == ListChangeAction.Add) ||
                (action == ListChangeAction.Remove) ||
                    (action == ListChangeAction.Reset)).AssertTrue();

            if (action == ListChangeAction.Reset)
            {
                changedItem.AssertNull();
                this.InitializeAdd(action, null, -1);
            }
            else
            {
                this.InitializeAddOrRemove(action, new object[] { changedItem }, -1);
            }
        }
Example #11
0
        /// <summary>
        /// Applies the stack, being provided an Add Item action and
        /// a Remove Item action
        /// </summary>
        /// <param name="addCallback"></param>
        /// <param name="removeCallback"></param>
        public void ApplyStack(ListChangeAction addCallback, ListChangeAction removeCallback)
        {
            while (modificationsStack.Count > 0)
            {
                KeyValuePair <ElementType, ListModificationType> mod =
                    modificationsStack.Pop();

                switch (mod.Value)
                {
                case ListModificationType.ADD:
                    addCallback(mod.Key);
                    break;

                case ListModificationType.REMOVE:
                    removeCallback(mod.Key);
                    break;
                }
            }
        }
Example #12
0
        public ListChangeEventArgs(ListChangeAction action, IList changedItems, int startingIndex)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            ((action == ListChangeAction.Add) ||
             (action == ListChangeAction.Remove) ||
             (action == ListChangeAction.Reset)).AssertTrue();

            if (action == ListChangeAction.Reset)
            {
                changedItems.AssertNull();
                (startingIndex == -1).AssertTrue();
                this.InitializeAdd(action, null, -1);
            }
            else
            {
                changedItems.AssertNotNull();
                (startingIndex != -1).AssertTrue();
                this.InitializeAddOrRemove(action, changedItems, startingIndex);
            }
        }
Example #13
0
        public ListChangeEventArgs(ListChangeAction action, IList changedItems, int index, int oldIndex)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            (action == ListChangeAction.Move).AssertTrue();
            (index >= 0).AssertTrue();
            this.InitializeMoveOrReplace(action, changedItems, changedItems, index, oldIndex);
        }
Example #14
0
        public ListChangeEventArgs(ListChangeAction action, IList newItems, IList oldItems)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            (action == ListChangeAction.Replace).AssertTrue();
            (newItems != null && oldItems != null).AssertTrue();
            this.InitializeMoveOrReplace(action, newItems, oldItems, -1, -1);
        }
Example #15
0
 private void InitializeMoveOrReplace(ListChangeAction action, IList newItems, IList oldItems, int startingIndex, int oldStartingIndex)
 {
     this.InitializeAdd(action, newItems, startingIndex);
     this.InitializeRemove(action, oldItems, oldStartingIndex);
 }
Example #16
0
 private void InitializeRemove(ListChangeAction action, IList oldItems, int oldStartingIndex)
 {
     this.Action           = action;
     this.OldItems         = ArrayList.ReadOnly(oldItems ?? new ArrayList());
     this.OldStartingIndex = oldStartingIndex;
 }
Example #17
0
 private void InitializeAdd(ListChangeAction action, IList newItems, int newStartingIndex)
 {
     this.Action           = action;
     this.NewItems         = ArrayList.ReadOnly(newItems ?? new ArrayList());
     this.NewStartingIndex = newStartingIndex;
 }
Example #18
0
 private void InitializeAdd(ListChangeAction action, IList newItems, int newStartingIndex)
 {
     this.Action = action;
     this.NewItems = ArrayList.ReadOnly(newItems ?? new ArrayList());
     this.NewStartingIndex = newStartingIndex;
 }
Example #19
0
 private void InitializeRemove(ListChangeAction action, IList oldItems, int oldStartingIndex)
 {
     this.Action = action;
     this.OldItems = ArrayList.ReadOnly(oldItems ?? new ArrayList());
     this.OldStartingIndex = oldStartingIndex;
 }
Example #20
0
 private void InitializeMoveOrReplace(ListChangeAction action, IList newItems, IList oldItems, int startingIndex, int oldStartingIndex)
 {
     this.InitializeAdd(action, newItems, startingIndex);
     this.InitializeRemove(action, oldItems, oldStartingIndex);
 }
Example #21
0
 private void InitializeAddOrRemove(ListChangeAction action, IList changedItems, int startingIndex)
 {
     if (action == ListChangeAction.Add)
     {
         this.InitializeAdd(action, changedItems, startingIndex);
     }
     else if (action == ListChangeAction.Remove)
     {
         this.InitializeRemove(action, changedItems, startingIndex);
     }
     else
     {
         AssertionHelper.Fail();
     }
 }
Example #22
0
        public ListChangeEventArgs(ListChangeAction action, object newItem, object oldItem, int index)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            (action == ListChangeAction.Replace).AssertTrue();
            this.InitializeMoveOrReplace(action, new object[] { newItem }, new object[] { oldItem }, index, index);
        }
Example #23
0
        public ListChangeEventArgs(ListChangeAction action, object changedItem, int index, int oldIndex)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            (action == ListChangeAction.Move).AssertTrue();
            (index >= 0).AssertTrue();

            var newItems = new object[] { changedItem };
            this.InitializeMoveOrReplace(action, newItems, newItems, index, oldIndex);
        }
Example #24
0
        public ListChangeEventArgs(ListChangeAction action, IList changedItems, int startingIndex)
        {
            this.NewStartingIndex = -1;
            this.OldStartingIndex = -1;

            ((action == ListChangeAction.Add) ||
                (action == ListChangeAction.Remove) ||
                    (action == ListChangeAction.Reset)).AssertTrue();

            if (action == ListChangeAction.Reset)
            {
                changedItems.AssertNull();
                (startingIndex == -1).AssertTrue();
                this.InitializeAdd(action, null, -1);
            }
            else
            {
                changedItems.AssertNotNull();
                (startingIndex != -1).AssertTrue();
                this.InitializeAddOrRemove(action, changedItems, startingIndex);
            }
        }