public void UpdatePropertySetProperties(ICollectionChange <PropertySetProperty> itemsCollection, PropertySet parentItem)
        {
            var repository = Repository;

            foreach (var removedItem in itemsCollection.RemovedItems)
            {
                var item = parentItem.PropertySetProperties.FirstOrDefault(x => x.PropertySetPropertyId == removedItem.PropertySetPropertyId);
                if (item != null)
                {
                    parentItem.PropertySetProperties.Remove(item);
                }
            }

            // priority could have changed
            foreach (var updatedItem in itemsCollection.UpdatedItems)
            {
                var item = parentItem.PropertySetProperties.SingleOrDefault(x => x.PropertySetPropertyId == updatedItem.PropertySetPropertyId);
                if (item != null)
                {
                    item.InjectFrom(updatedItem);
                }
            }

            foreach (var addedItem in itemsCollection.AddedItems)
            {
                parentItem.PropertySetProperties.Add(addedItem);
            }

            var disposableCollection = itemsCollection as IDisposable;

            if (disposableCollection != null)
            {
                disposableCollection.Dispose();
            }
        }
예제 #2
0
        private void applyCollectionChange(ICollectionChange <ContentType, ContentType> contentContentChange, out ICollectionChangeBundle <ItemType, ContentType> appliedBundle)
        {
            var itemContentChange = CreateItemContentCollectionChange(contentContentChange);
            var applyingBundle    = new ApplyingCollectionChangeBundle(itemContentChange, contentContentChange);

            ApplyCollectionChangeBundle(applyingBundle);
            appliedBundle = GetAppliedCollectionChangeBundle(applyingBundle);
        }
 public CollectionChangeBundle(ICollectionChange <ItemType, ItemType> itemItemChange,
                               ICollectionChange <ItemType, ContentType> itemContentChange,
                               ICollectionChange <ContentType, ContentType> contentContentChange)
 {
     ItemItemChange       = itemItemChange;
     ItemContentChange    = itemContentChange;
     ContentContentChange = contentContentChange;
 }
예제 #4
0
        public virtual async Task ApplyCollectionChangeAsync(ICollectionChange <ContentType, ContentType> contentContentChange)
        {
            applyCollectionChange(contentContentChange, out var appliedBundle);
            var eventSequence = new AsyncEventSequence();
            var args          = new CollectionChangeAppliedEventArgs <ItemType, ContentType>(appliedBundle, eventSequence);

            OnCollectionChangeApplied(args);
            await eventSequence.FinishDependenciesAsync();
        }
예제 #5
0
        public void OnNext(ICollectionChange <T> value)
        {
            var added   = value.Added.Where(pred);
            var removed = value.Removed.Where(pred);

            if (!added.IsEmpty || !removed.IsEmpty)
            {
                signal.Fire(new CollectionChange <T>(added, removed));
            }
        }
예제 #6
0
        private IEnumerable <int> updateTable(ICollectionChange change)
        {
            var affectedSections = new List <int>();

            switch (change)
            {
            case AddRowCollectionChange <TModel> addRow:
                add(addRow);
                affectedSections.Add(addRow.Index.Section);
                break;

            case InsertSectionCollectionChange <TModel> insert:
                insertSection(insert);
                break;

            case RemoveRowCollectionChange removeRow:
                var oldSectionWasRemoved = remove(removeRow);
                if (!oldSectionWasRemoved)
                {
                    affectedSections.Add(removeRow.Index.Section);
                }

                break;

            case MoveRowWithinExistingSectionsCollectionChange <TModel> moveRow:
                var oldAndNewSection = move(moveRow);
                affectedSections.AddRange(oldAndNewSection);
                break;

            case MoveRowToNewSectionCollectionChange <TModel> moveRowToNewSection:
                var affectedSection = move(moveRowToNewSection);
                if (affectedSection.HasValue)
                {
                    affectedSections.Add(affectedSection.Value);
                }

                break;

            case UpdateRowCollectionChange <TModel> updateRow:
                update(updateRow);
                affectedSections.Add(updateRow.Index.Section);
                break;

            case ReloadCollectionChange reload:
                tableView.ReloadData();
                break;
            }

            return(affectedSections);
        }
예제 #7
0
        public virtual async Task ApplyCollectionChangeAsync(ICollectionChange <ItemType, ContentType> itemContentChange)
        {
            BeginWork();

            try {
                applyCollectionChange(itemContentChange, out var appliedBundle);
                var eventSequence = new AsyncEventSequence();
                var args          = new CollectionChangeAppliedEventArgs <ItemType, ContentType>(appliedBundle, eventSequence);
                OnCollectionChangeApplied(args);
                await eventSequence.FinishDependenciesAsync();
            } finally {
                EndWork();
            }
        }
        private void handleCollectionChange(ICollectionChange change)
        {
            lock (animationLock)
            {
                tableView.BeginUpdates();

                var sectionsNeedingHeaderRefresh = updateTable(change);
                dataSource.ChangeDisplayedCollection(change);

                tableView.EndUpdates();

                sectionsNeedingHeaderRefresh.ForEach(index =>
                                                     dataSource.RefreshHeader(tableView, index));
            }
        }
예제 #9
0
        public void UpdateCollection(ICollectionChange change)
        {
            lock (collectionUpdateLock)
            {
                if (isUpdateRunning)
                {
                    hasPendingUpdate = true;
                    return;
                }

                isUpdateRunning = true;
            }

            startCurrentCollectionUpdate();
        }
        public void UpdateOfLanguages(ICollectionChange <GeneralLanguage> languagesVm)
        {
            var repository = Repository as IShippingRepository;
            {
                foreach (var removedItem in languagesVm.RemovedItems)
                {
                    var item = InnerItem.ShippingMethodLanguages.FirstOrDefault(x => x.ShippingMethodLanguageId == removedItem.Id);
                    if (item == null)
                    {
                        continue;
                    }

                    InnerItem.ShippingMethodLanguages.Remove(item);
                    repository.Attach(item);
                    repository.Remove(item);
                }

                foreach (var updatedItem in languagesVm.UpdatedItems)
                {
                    var item = InnerItem.ShippingMethodLanguages.SingleOrDefault(x => x.ShippingMethodLanguageId == updatedItem.Id);
                    if (item == null)
                    {
                        continue;
                    }
                    item.InjectFrom(updatedItem);
                }

                foreach (var addedItem in languagesVm.AddedItems)
                {
                    var item = EntityFactory.CreateEntity <ShippingMethodLanguage>();
                    item.InjectFrom(addedItem);
                    InnerItem.ShippingMethodLanguages.Add(item);
                }

                if (!IsWizardMode)
                {
                    repository.UnitOfWork.Commit();
                }
            }
        }
        public void ChangeDisplayedCollection(ICollectionChange change)
        {
            switch (change)
            {
            case InsertSectionCollectionChange <TModel> insert:
                insertSection(insert.Index, insert.Item);
                break;

            case AddRowCollectionChange <TModel> addRow:
                add(addRow.Index, addRow.Item);
                break;

            case RemoveRowCollectionChange removeRow:
                remove(removeRow.Index);
                break;

            case MoveRowToNewSectionCollectionChange <TModel> moveRowToNewSection:
                remove(moveRowToNewSection.OldIndex);
                insertSection(moveRowToNewSection.Index, moveRowToNewSection.Item);
                break;

            case MoveRowWithinExistingSectionsCollectionChange <TModel> moveRow:
                remove(moveRow.OldIndex);
                add(moveRow.Index, moveRow.Item);
                break;

            case UpdateRowCollectionChange <TModel> updateRow:
                update(updateRow.Index, updateRow.Item);
                break;

            case ReloadCollectionChange _:
                reloadDisplayedData();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void UpdateChange(ICollectionChange change)
        {
            switch (change)
            {
            case AddRowCollectionChange <TModel> addRow:
                updateSectionIndexes();
                NotifyItemInserted(mapSectionIndexToAdapterIndex(addRow.Index));
                NotifyItemChanged(sectionsIndexes[addRow.Index.Section] + HeaderOffset);
                break;

            case InsertSectionCollectionChange <TModel> insertSection:
                updateSectionIndexes();
                NotifyItemRangeInserted(sectionsIndexes[insertSection.Index] + HeaderOffset, 2);
                break;

            case UpdateRowCollectionChange <TModel> updateRow:
                NotifyItemChanged(mapSectionIndexToAdapterIndex(updateRow.Index));
                NotifyItemChanged(sectionsIndexes[updateRow.Index.Section] + HeaderOffset);
                break;

            case MoveRowWithinExistingSectionsCollectionChange <TModel> moveRowWithinExistingSectionsCollectionChange:
                moveRowWithinExistingSections(moveRowWithinExistingSectionsCollectionChange);
                break;

            case MoveRowToNewSectionCollectionChange <TModel> moveRowToNewSection:
                this.moveRowToNewSection(moveRowToNewSection);
                break;

            case RemoveRowCollectionChange removeRow:
                this.removeRow(removeRow);
                break;

            case ReloadCollectionChange reload:
                updateSectionIndexes();
                NotifyDataSetChanged();
                break;
            }
        }
        private IEnumerable <UpdateWithTargetContainer <ContentType, ItemType> > getOldItemUpdateContainerIterator(ICollectionChange <ItemType, ContentType> change)
        {
            if (change.Action == NotifyCollectionChangedAction.Replace)
            {
                var oldItems = change.OldItems ??
                               throw new ArgumentException("The old item-item-items were not given that can be processed as collection change");

                var newItems = change.NewItems ??
                               throw new ArgumentException("The new item-item-items were not given that can be processed as collection change");

                var oldItemsEnumerator = oldItems.GetEnumerator();
                var newItemsEnumerator = newItems.GetEnumerator();

                while (oldItemsEnumerator.MoveNext() && newItemsEnumerator.MoveNext())
                {
                    var oldItem                = oldItemsEnumerator.Current;
                    var newItem                = newItemsEnumerator.Current;
                    var oldItemUpdate          = new ContentUpdate <ContentType>(newItem, this);
                    var oldItemUpdateContainer = new UpdateWithTargetContainer <ContentType, ItemType>(oldItemUpdate, oldItem);
                    yield return(oldItemUpdateContainer);
                }
            }
        }
예제 #14
0
        public ICollectionChange <ItemType, ContentType> CreateItemContentCollectionChange(ICollectionChange <ContentType, ContentType> contentContentChange)
        {
            var oldItems          = contentContentChange.GetOldItems(ItemList);
            var itemContentChange = contentContentChange.CreateOf(oldItems, contentContentChange.NewItems);

            return(itemContentChange);
        }
예제 #15
0
 public virtual void ApplyCollectionChange(ICollectionChange <ContentType, ContentType> contentContentChange) =>
 AsyncHelper.RunSynchronous(() => ApplyCollectionChangeAsync(contentContentChange));
        private bool RaisePropertySetEditInteractionRequest(PropertySet item, string title, out ICollectionChange <PropertySetProperty> itemsCollection)
        {
            var result = false;
            var itemVM = _propertySetVmFactory.GetViewModelInstance(
                new KeyValuePair <string, object>("item", item),
                new KeyValuePair <string, object>("properties", CurrentCatalogProperties));
            var confirmation = new ConditionalConfirmation(itemVM.Validate)
            {
                Title = title, Content = itemVM
            };

            CommonConfirmRequest.Raise(confirmation, (x) =>
            {
                result = x.Confirmed;
            });
            itemsCollection = itemVM.GetItemsCollection();

            return(result);
        }
예제 #17
0
            //public AsyncEventSequence? EventSequence { get; private set; }

            //public AppliedCollectionChangeBundle(ICollectionChange<ItemType, ItemType> itemItemChange,
            //    ICollectionChange<ItemType, ContentType> itemContentChange,
            //    ICollectionChange<ContentType, ContentType> contentContentChange, AsyncEventSequence? eventSequence)
            //    : base(itemItemChange, itemContentChange, contentContentChange)
            //    => EventSequence = eventSequence;

            public AppliedCollectionChangeBundle(ICollectionChange <ItemType, ItemType> itemItemChange,
                                                 ICollectionChange <ItemType, ContentType> itemContentChange,
                                                 ICollectionChange <ContentType, ContentType> contentContentChange)
                : base(itemItemChange, itemContentChange, contentContentChange)
            {
            }
예제 #18
0
        public ICollectionChange <ContentType, ContentType> CreateContentContentCollectionChange(ICollectionChange <ItemType, ContentType> itemContentChange)
        {
            var oldItems             = itemContentChange.GetNewItems(ContentList);
            var contentContentChange = itemContentChange.CreateOf(oldItems, itemContentChange.NewItems);

            return(contentContentChange);
        }