/// <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()); } }
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); }
/// <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)); }
/// <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)); }
public static bool Contains(this IStore store, StoredObjectId soId) { var item = store.Get(soId); return(item != null); }
public static bool Exists(this IStore store, StoredObjectId id) { var item = store.Get(id); return(item != null); }