Пример #1
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Called when any property of an item changes.
        /// </summary>
        //------------------------------------------------------------------------------------
        public void SaveProperty(ItemProperty itemProperty)
        {
            StoreItem  item       = itemProperty.Item;
            ChangeType changeType = ChangeType.Updated;

            // Items in these persist states by definition have no changes to be saved.
            if (item.PersistState == PersistStates.Dummy || item.PersistState == PersistStates.NewUncommitted)
            {
                return;
            }

            // Maintain the change list
            UpdateChangeList(item);

            // If the Resolution property has changed, the item is moving to or from the deleted state
            if (itemProperty.PublicPropName == StringUtils.GetPropertyName((StoreItem p) => p.Resolution))
            {
                // Item is being deleted
                if (item.Resolution == ResolutionType.WontFix)
                {
                    // If the item isn't dirty, then the resolution has been completed, and the property
                    // change above is the backing value catching up to the current value.
                    if (itemProperty.IsValueChanged())
                    {
                        if (RemoveFromCache(item))
                        {
                            changeType        = ChangeType.Removed;
                            item.ChangeAction = StoreChangeAction.ResolveAndCloseItem;

                            // If the item has never been saved, just remove from the change list
                            if (item.IsNew)
                            {
                                m_changedItems.Remove(item);
                            }
                        }
                    }
                }

                // If item was undone back to active, bring it back into the cache.
                else if (string.IsNullOrWhiteSpace(item.Resolution))
                {
                    if (AddToCache(item))
                    {
                        changeType        = ChangeType.Added;
                        item.ChangeAction = StoreChangeAction.Default;
                    }
                }
            }

            if (changeType == ChangeType.Updated)
            {
                item.OnUpdate(itemProperty);
                SendItemChangedEvent(item, ChangeType.Updated, itemProperty);
            }
        }