Example #1
0
        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)));
        }
Example #2
0
        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)));
        }
Example #3
0
        private SerializedIHasId(IHasId obj)
        {
            Condition.Requires(obj).IsNotNull();

            var id = obj.GetStoredObjectId();

            this.Id      = _serializer.Serialize(id);
            this.Context = _serializer.Serialize(obj);
        }
Example #4
0
        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));
        }
Example #5
0
        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));
        }