Example #1
0
        internal static ChangeArgs ItemsAdded(
            IVMCollection collection,
            IEnumerable <IViewModel> newItems,
            IChangeReason reason = null
            )
        {
            Check.NotNull(collection, nameof(collection));
            Check.NotNull(newItems, nameof(newItems));
            Check.NotEmpty(newItems, nameof(newItems));

            return(new ChangeArgs(
                       ChangeType.AddedToCollection,
                       ValueStage.ValidatedValue,
                       Path.Empty.Append(collection),
                       newItems: newItems,
                       reason: reason
                       ));
        }
Example #2
0
        internal static ChangeArgs CollectionPopulated(
            IVMCollection collection,
            IEnumerable <IViewModel> oldItems,
            IChangeReason reason = null
            )
        {
            Check.NotNull(collection, nameof(collection));

            var newItems = (IEnumerable <IViewModel>)collection;

            return(new ChangeArgs(
                       ChangeType.CollectionPopulated,
                       ValueStage.ValidatedValue,
                       Path.Empty.Append(collection),
                       newItems: newItems,
                       oldItems: oldItems,
                       reason: reason
                       ));
        }
        private void Repopulate(IBehaviorContext context, IVMCollection <TItemVM> collection, IChangeReason reason)
        {
            var sourceItems = GetSourceItems(context);

            IEnumerable <TItemVM> newItems = sourceItems
                                             .Select(s => CreateAndInitializeItem(context, s));

            collection.ReplaceItems(newItems, reason);
        }
 public virtual void ReplaceItems(IEnumerable <TItemVM> newItems, IChangeReason reason)
 {
     Clear();
     newItems.ForEach(Add);
 }
Example #5
0
 public override void ReplaceItems(IEnumerable <ItemVM> newItems, IChangeReason reason)
 {
     _log.Append(ReplaceItemsLog);
     base.ReplaceItems(newItems, reason);
 }
Example #6
0
        internal static ChangeArgs PropertyChanged(IVMPropertyDescriptor property, ValueStage stage, IChangeReason reason = null)
        {
            Check.NotNull(property, nameof(property));

            return(new ChangeArgs(
                       ChangeType.PropertyChanged,
                       stage,
                       Path.Empty.Append(property),
                       reason: reason
                       )
            {
                ChangedProperty = property
            });                           // TODO: Remove
        }
        private void Repopulate(IBehaviorContext context, IVMCollection <TItemVM> collection, IChangeReason reason)
        {
            var sourceItems = this.GetValueNext <IEnumerable <TItemSource> >(context);

            var items = sourceItems
                        .Select(sourceItem => GetItemVM(context, sourceItem));

            collection.ReplaceItems(items, reason);
        }