예제 #1
0
 public virtual T Update(T item)
 {
     if (_updateableBiggyStore != null)
     {
         _updateableBiggyStore.Update(item);
     }
     else
     {
         _store.SaveAll(_items);
     }
     Fire(Changed, item: item);
     return(item);
 }
예제 #2
0
        public void SaveAll(List <T> items)
        {
            _biggyStore.SaveAll(items);

            _luceneIndexer.DeleteAll();
            _luceneIndexer.AddDocumentsToIndex(items);
        }
예제 #3
0
파일: BiggyList.cs 프로젝트: grufffta/biggy
        public virtual T Update(T item)
        {
            T itemFromList = default(T);

            if (!_items.Contains(item))
            {
                // Figure out what to do here. Retreive Key From Store and evaluate?
                throw new InvalidOperationException(
                          @"The list does not contain a reference to the object passed as an argument. 
          Make sure you are passing a valid reference, or override Equals on the type being passed.");
            }
            else
            {
                itemFromList = _items.ElementAt(_items.IndexOf(item));
                if (!ReferenceEquals(itemFromList, item))
                {
                    //// The items are "equal" but do not refer to the same instance.
                    //// Somebody overrode Equals on the type passed as an argument. Replace:
                    int index = _items.IndexOf(item);
                    _items.RemoveAt(index);
                    _items.Insert(index, item);
                }
                // From here forward, the item passed in refers to the item in the list.
            }
            if (_store != null && !this.InMemory)
            {
                if (_updateableStore != null && !this.InMemory)
                {
                    _updateableStore.Update(item);
                }
                else
                {
                    _store.SaveAll(_items);
                }
            }
            Fire(Changed, item: item);
            return(item);
        }