Beispiel #1
0
        /// <summary>
        /// moves an item from one store to the other
        /// </summary>
        /// <param name="store"></param>
        /// <param name="storeToMoveTo"></param>
        /// <param name="itemToMove"></param>
        public static void MoveItem(this IStore store, IStore storeToMoveTo, StoredObjectId itemToMove)
        {
            if (store == null)
            {
                return;
            }

            if (storeToMoveTo == null)
            {
                return;
            }

            var item = store.Get(itemToMove);

            if (item != null)
            {
                storeToMoveTo.SaveItem(item);
                store.DeleteItem(item.GetStoredObjectId());
            }
        }
Beispiel #2
0
        public ICommitBag MarkItemSaved(IHasId obj)
        {
            if (obj == null)
            {
                return(this);
            }

            //we don't allow StoredObjectIds...we have to be dealing with actual objects
            if (obj is StoredObjectId)
            {
                throw new InvalidOperationException("StoredObjectId type is not allowed");
            }

            lock (this._stateLock)
            {
                List <IHasId> list = this.ItemsToSave as List <IHasId>;

                list.RemoveAll(x => StoredObjectId.New(x).Equals(StoredObjectId.New(obj)));

                this.ItemsToSave.Add(obj);
            }
            return(this);
        }
Beispiel #3
0
 /// <summary>
 /// creates a stored object id for ContextualAsId
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static StoredObjectId CreateSOID4ContextualAsId <TId, TContext>(this TId obj)
 {
     return(StoredObjectId.New(typeof(ContextualId <TId, TContext>), obj));
 }
Beispiel #4
0
 /// <summary>
 /// creates a stored object id that points to AsHasId instance
 /// </summary>
 /// <typeparam name="TId"></typeparam>
 /// <typeparam name="T"></typeparam>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static StoredObjectId CreateSOID4AsHasId <TId, T>(this TId obj)
 {
     return(StoredObjectId.New(typeof(AsHasId <TId, T>), obj));
 }
Beispiel #5
0
        public static bool Contains(this IStore store, StoredObjectId soId)
        {
            var item = store.Get(soId);

            return(item != null);
        }
Beispiel #6
0
        public static bool Exists(this IStore store, StoredObjectId id)
        {
            var item = store.Get(id);

            return(item != null);
        }