public void SetIndex(IHasId obj) { Condition.Requires(obj).IsNotNull(); var hasBits = this.IndexFactory.GenerateIndex(obj); var soid = obj.GetStoredObjectId(); this._storeOfIndices.SaveItem(new IndexedEntry(soid.BuildAsId().HasBits(hasBits))); }
private SerializedIHasId(IHasId obj) { Condition.Requires(obj).IsNotNull(); var id = obj.GetStoredObjectId(); this.Id = _serializer.Serialize(id); this.Context = _serializer.Serialize(obj); }
public static void SaveItemIfUniqueElseThrow(this IStore store, IHasId obj) { if (store == null) return; //throw if the item exists var dup = store.Get(obj.GetStoredObjectId()); if (dup != null) throw new InvalidOperationException("Item already exists " + obj.Id.ToString()); store.Commit(new CommitBag().MarkItemSaved(obj)); }
public static void SaveItemIfUniqueElseThrow(this IStore store, IHasId obj) { if (store == null) { return; } //throw if the item exists var dup = store.Get(obj.GetStoredObjectId()); if (dup != null) { throw new InvalidOperationException("Item already exists " + obj.Id.ToString()); } store.Commit(new CommitBag().MarkItemSaved(obj)); }