Esempio n. 1
0
        private void NotifyChange(Identity elementId, NotifyCollectionChangedAction defaultAction, IModelElement item)
        {
            int index = _items.IndexOf(elementId);

            if (defaultAction == NotifyCollectionChangedAction.Remove)
            {
                if (index >= 0)
                {
                    if (item == null && DomainModel is Hyperstore.Modeling.Domain.ICacheAccessor)
                    {
                        item = ((Hyperstore.Modeling.Domain.ICacheAccessor)DomainModel).TryGetFromCache(elementId);
                    }
                    _synchronizationContext.Send(() => OnCollectionChanged(item, NotifyCollectionChangedAction.Remove, index));
                    _items.RemoveAt(index);
                }
                return;
            }

            if (index >= 0)
            {
                return;
            }

            if (item == null)
            {
                item = (T)DomainModel.Store.GetElement(elementId);
            }

            if (item == null || WhereClause != null && !WhereClause((T)item))
            {
                return;
            }

            //index = IndexOfCore(elementId);
            //if (index == -1)
            //    return;

            index = _items.Count;
            _items.Add(elementId);
            _synchronizationContext.Send(() => OnCollectionChanged(item, NotifyCollectionChangedAction.Add, index));
        }