Beispiel #1
0
 public CollectionChange(CollectionChangeType type, int sourceIndex, int destinationIndex, int count)
 {
     Type             = type;
     SourceIndex      = sourceIndex;
     DestinationIndex = destinationIndex;
     Count            = count;
 }
Beispiel #2
0
 private void OnChange(T item, CollectionChangeType type)
 {
     if (Change != null)
     {
         this.Change(item, type);
     }
 }
Beispiel #3
0
 void Notify(CollectionChangeType type, T item)
 {
     if (this.Changed != null)
     {
         this.Changed(type, item);
     }
 }
 public void RaisePrimitiveCollectionChanged(ICartesianPrimitive primitive, CollectionChangeType changeType)
 {
     PrimitiveCollectionChanged(this,
                                new PrimitiveCollectionChangedEventArgs()
     {
         Primitive = primitive,
         IsAdded   = changeType
     });
 }
Beispiel #5
0
 /// <summary>
 /// Constructor used for add/delete/replace
 /// </summary>
 /// <param name="coll">Collection to work with</param>
 /// <param name="type">Type of change</param>
 /// <param name="oldPos">Position of change</param>
 /// <param name="newPos">New position of change</param>
 /// <param name="oldValue">Old value at position</param>
 /// <param name="newValue">New value at position</param>
 public CollectionChangeUndo(IList coll, CollectionChangeType type,
                             int oldPos, int newPos, object oldValue, object newValue)
 {
     _collection = coll;
     _changeType = type;
     _pos        = oldPos;
     _newPos     = newPos;
     _oldValue   = oldValue;
     _newValue   = newValue;
 }
        public void AddCollectionChangedItem_Adds_ChangedItem(CollectionChangeType changeType)
        {
            // arrange
            var entity = TestHelper.CreateEntityWithId <Artist>(1);
            var propertyChangeTracker = new PropertyChangeTracker(entity);

            // act
            propertyChangeTracker.AddCollectionChangedItem(new CollectionChangedItem("StatisticValues", null, changeType));

            // assert
            Assert.True(propertyChangeTracker.HasChanged <Artist>(x => x.StatisticValues));
        }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectionChangeUndo"/> class.
        /// </summary>
        /// <param name="collection">Collection to work with.</param>
        /// <param name="type">Type of change.</param>
        /// <param name="oldPosition">Position of change.</param>
        /// <param name="newPosition">New position of change.</param>
        /// <param name="oldValue">Old value at position.</param>
        /// <param name="newValue">New value at position.</param>
        /// <param name="tag">The tag.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="collection" /> is <c>null</c>.</exception>
        public CollectionChangeUndo(IList collection, CollectionChangeType type, int oldPosition, int newPosition,
                                    object oldValue, object newValue, object tag = null)
            : base(collection, tag)
        {
            Argument.IsNotNull("collection", collection);

            ChangeType  = type;
            Position    = oldPosition;
            NewPosition = newPosition;
            OldValue    = oldValue;
            NewValue    = newValue;

            CanRedo = true;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectionChangeUndo"/> class.
        /// </summary>
        /// <param name="collection">Collection to work with.</param>
        /// <param name="type">Type of change.</param>
        /// <param name="oldPosition">Position of change.</param>
        /// <param name="newPosition">New position of change.</param>
        /// <param name="oldValue">Old value at position.</param>
        /// <param name="newValue">New value at position.</param>
        /// <param name="tag">The tag.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="collection" /> is <c>null</c>.</exception>
        public CollectionChangeUndo(IList collection, CollectionChangeType type, int oldPosition, int newPosition, 
            object oldValue, object newValue, object tag = null)
            : base(collection, tag)
        {
            Argument.IsNotNull("collection", collection);

            ChangeType = type;
            Position = oldPosition;
            NewPosition = newPosition;
            OldValue = oldValue;
            NewValue = newValue;

            CanRedo = true;
        }
Beispiel #9
0
        /// <summary>
        /// Tries to get the changed collection items.
        /// </summary>
        /// <param name="propertyName">The property name.</param>
        /// <param name="changeType">The collection change type.</param>
        /// <param name="items">The items.</param>
        /// <returns>Returns true if the changed values could be recovered.</returns>
        public bool TryGetChangedCollectionItems(string propertyName, CollectionChangeType changeType, out List <Entity> items)
        {
            items = new List <Entity>();

            var collectionChanges = _collectionChangedItems.Where(x => x.PropertyName == propertyName && x.CollectionChangeType == changeType);

            if (!collectionChanges.Any())
            {
                return(false);
            }

            items = collectionChanges.Select(x => x.Item).ToList();
            return(true);
        }
        public void AddCollectionChangedItem_Prevents_Unneccessary_Changes(CollectionChangeType changeType)
        {
            // arrange
            var entity = TestHelper.CreateEntityWithId <Artist>(1);
            var propertyChangeTracker = new PropertyChangeTracker(entity);
            var oppositeChangeType    = changeType == CollectionChangeType.Added ? CollectionChangeType.Removed : CollectionChangeType.Added;
            var statisticValue        = new ArtistStatisticValues();

            // act
            propertyChangeTracker.AddCollectionChangedItem(new CollectionChangedItem("StatisticValues", statisticValue, changeType));
            propertyChangeTracker.AddCollectionChangedItem(new CollectionChangedItem("StatisticValues", statisticValue, oppositeChangeType));

            // assert
            Assert.False(propertyChangeTracker.HasChanged <Artist>(x => x.StatisticValues));
        }
 private CollectionChangedArgs(
     CollectionChangeType type,
     IVMCollection <TItemVM> collection,
     IEnumerable <TItemVM> oldItems = null,
     IEnumerable <TItemVM> newItems = null,
     IChangeReason reason           = null
     )
 {
     Type       = type;
     Collection = collection;
     Index      = -1;
     OldItems   = oldItems ?? Enumerable.Empty <TItemVM>();
     NewItems   = newItems ?? Enumerable.Empty <TItemVM>();
     Reason     = reason;
 }
Beispiel #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectionChangedEventArgs&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="changeType">Type of the change.</param>
        /// <param name="index">The index.</param>
        /// <param name="oldIndex">The old index.</param>
        /// <param name="item">The item.</param>
        public CollectionChangedEventArgs(CollectionChangeType changeType, int index, int oldIndex, T item)
        {
            //if( trace.IsDebugLevel )
            //{
            //    trace.Debug( "CollectionChangedEventArgs.ctor( CollectionChangeType, int, {0} )", typeof( T ).Name );
            //    trace.Debug( "changeType: {0}", changeType );
            //    trace.Debug( "index: {0}", index );
            //    trace.Debug( "oldIndex: {0}", oldIndex );
            //    trace.Debug( "item: {0}", item == null ? "<null>" : item.ToString() );
            //}

            this.ChangeType = changeType;
            this.Index      = index;
            this.OldIndex   = oldIndex;
            this.Item       = item;
        }
 private CollectionChangedArgs(
     CollectionChangeType type,
     IVMCollection <TItemVM> collection,
     int index,
     TItemVM oldItem = default(TItemVM),
     TItemVM newItem = default(TItemVM)
     )
 {
     Type       = type;
     Collection = collection;
     Index      = index;
     OldItem    = oldItem;
     OldItems   = oldItem != null ? new[] { oldItem } : Enumerable.Empty <TItemVM>();
     NewItem    = newItem;
     NewItems   = newItem != null ? new[] { newItem } : Enumerable.Empty <TItemVM>();
 }
Beispiel #14
0
 public DictionaryEventArgs(CollectionChangeType changeType, object[] keys, object[] newItems, object[] oldItems = null)
     : base(changeType, newItems, oldItems)
 {
     this.Keys = keys;
 }
Beispiel #15
0
 /// <summary>
 /// Initializes a new CollectionChange
 /// </summary>
 /// <param name="propertyName">The property name.</param>
 /// <param name="item">The entity item.</param>
 /// <param name="changeType">The collection changed type.</param>
 public CollectionChangedItem(string propertyName, Entity item, CollectionChangeType changeType)
 {
     PropertyName         = propertyName;
     Item                 = item;
     CollectionChangeType = changeType;
 }
Beispiel #16
0
 protected CollectionEventArgs(CollectionChangeType changeType, object[] newItems, object[] oldItems = null)
 {
     this.ChangeType = changeType;
     this.Items      = newItems;
     this.OldItems   = oldItems ?? emptyArray;
 }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionChangedEventArgs"/> class.
 /// </summary>
 /// <param name="changeType">Type of the change.</param>
 public CollectionChangedEventArgs(CollectionChangeType changeType) : base()
 {
     _changeType = changeType;
 }
Beispiel #18
0
 public CollectionChange(object item, int index, CollectionChangeType type)
 {
     Item     = item;
     OldIndex = NewIndex = index;
     Type     = type;
 }
 public CollectionChangeEvent(CollectionChangeType type)
 {
     Type = type;
 }
Beispiel #20
0
 /// <summary>
 /// Creates new instance.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="type"></param>
 public CollectionChangedEventArgs(ITypeDescriptorContext context, CollectionChangeType type)
 {
     this.Context = context;
     this.Type    = type;
 }
Beispiel #21
0
 public IEnumerable <IJsCsGlue> GetGlues(CollectionChangeType @type) => IndividualChanges.Where(ch => ch.CollectionChangeType == @type).Select(change => change.Glue);
Beispiel #22
0
        /// <summary>
        /// Tries to get the changed collection items.
        /// </summary>
        /// <typeparam name="T">The entity type.</typeparam>
        /// <typeparam name="TEntityItem">The collection item type.</typeparam>
        /// <param name="expression">The expression.</param>
        /// <param name="changeType">The collection change type.</param>
        /// <param name="items">The changed items.</param>
        /// <returns>Returns true if the changed values could be recovered.</returns>
        public bool TryGetChangedCollectionItems <T, TEntityItem>(Expression <Func <T, object> > expression, CollectionChangeType changeType, out List <TEntityItem> items) where T : Entity
        {
            items = new List <TEntityItem>();

            var collectionChanges = _collectionChangedItems.Where(x => x.PropertyName == GetPropertyName(expression) && x.CollectionChangeType == changeType);

            if (!collectionChanges.Any())
            {
                return(false);
            }

            items = collectionChanges.Select(x => x.Item).OfType <TEntityItem>().ToList();
            return(true);
        }
Beispiel #23
0
 public IndividualJavascriptCollectionChange(CollectionChangeType collectionChange, int index, IJavascriptObject @object)
 {
     CollectionChangeType = collectionChange;
     Index  = index;
     Object = @object;
 }
Beispiel #24
0
 /// <summary>
 /// Adds a new collection changed item.
 /// </summary>
 /// <param name="property">The property.</param>
 /// <param name="entityItem">The added or removed entity.</param>
 /// <param name="changeType">The collection change type.</param>
 public void AddCollectionChangedItem(string property, Entity entityItem, CollectionChangeType changeType)
 {
     AddCollectionChangedItem(new CollectionChangedItem(property, entityItem, changeType));
 }
 public IndividualJavascriptCollectionChange(CollectionChangeType iCollectionChange, int iIndex, IJavascriptObject iObject)
 {
     CollectionChangeType=iCollectionChange;
      Index=   iIndex;
      Object = iObject;
 }
 public IndividualCollectionChange(CollectionChangeType iCollectionChange, int iIndex, IJSCSGlue iObject)
 {
     CollectionChangeType=iCollectionChange;
      Index=   iIndex;
      Object = iObject;
 }
Beispiel #27
0
 public IndividualJavascriptCollectionChange(CollectionChangeType iCollectionChange, int iIndex, IJavascriptObject iObject)
 {
     CollectionChangeType = iCollectionChange;
     Index  = iIndex;
     Object = iObject;
 }
Beispiel #28
0
 public CollectionChangedEventArgs(CollectionChangeType type)
 {
     changeType = type;
 }
Beispiel #29
0
 public CollectionChangedEventArgs(CollectionChangeType type)
 {
     changeType = type;
 }
 public CollectionChangeEvent(IStatusUpdate item, CollectionChangeType type)
 {
     Item = item;
     Type = type;
 }
 public IndividualCollectionChange(CollectionChangeType iCollectionChange, int iIndex, IJSCSGlue iObject)
 {
     CollectionChangeType = iCollectionChange;
     Index  = iIndex;
     Object = iObject;
 }
 public CollectionChangeEvent(object item, int index, CollectionChangeType type)
 {
     Item = item;
     OldIndex = NewIndex = index;
     Type = type;
 }
Beispiel #33
0
 /// <summary>
 /// Adds a new collection changed item.
 /// </summary>
 /// <typeparam name="T">The entity type.</typeparam>
 /// <param name="propertyExpression">The expression representing the local property.</param>
 /// <param name="entityItem">The added or removed entity.</param>
 /// <param name="changeType">The collection change type.</param>
 public void AddCollectionChangedItem <T>(Expression <Func <T, object> > propertyExpression, Entity entityItem, CollectionChangeType changeType) where T : Entity
 {
     AddCollectionChangedItem(GetPropertyName(propertyExpression), entityItem, changeType);
 }
Beispiel #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionChangedEventArgs&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="changeType">Type of the change.</param>
 public CollectionChangedEventArgs(CollectionChangeType changeType)
     : this(changeType, -1, -1, default(T))
 {
 }
Beispiel #35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CollectionChangedEventArgs&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="changeType">Type of the change.</param>
 /// <param name="index">The index.</param>
 public CollectionChangedEventArgs(CollectionChangeType changeType, int index)
     : this(changeType, index, -1, default(T))
 {
 }
Beispiel #36
0
 protected ListEventArgs(CollectionChangeType changeType, int[] indexes, object[] newItems, object[] oldItems = null)
     : base(changeType, newItems, oldItems)
 {
     this.Indices = indexes;
 }
Beispiel #37
0
 /// <summary>
 /// Called when the collection has been changed.
 /// </summary>
 /// <param name="changeType">Type of the change.</param>
 /// <remarks>Triggers the <see cref="CollectionChanged"/> event.</remarks>
 private void OnCollectionChanged(CollectionChangeType changeType)
 {
     OnCollectionChanged(this, new CollectionChangedEventArgs(changeType));
 }