Exemplo n.º 1
0
        public IAsyncAction NewItemAsync(RecordItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            SynchronizedStore.PrepareForNew(item);

            return(AsyncInfo.Run(async cancelToken =>
            {
                RecordItemLock rlock = m_itemLocks.AcquireItemLock(item.ID);
                if (rlock != null)
                {
                    using (rlock)
                    {
                        await this.PutItemAsync(item, rlock);
                    }
                }
            }));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add a new item. The item is saved in the local store immediately, and a pending commit to the remote store is put in
        /// the synchronized store's change queue
        /// </summary>
        public IAsyncAction AddNewAsync(IItemDataTyped item)
        {
            this.ValidateItem(item);

            RecordItem recordItem = item.Item;

            SynchronizedStore.PrepareForNew(recordItem);

            return(AsyncInfo.Run(async cancelToken => {
                RecordItemLock rlock = this.AcquireItemLock(recordItem.Key);
                if (rlock == null)
                {
                    return;
                }

                using (rlock)
                {
                    await this.Data.PutItemAsync(recordItem, rlock);
                    await this.AddKeyAsync(recordItem);
                }

                this.StartCommitChanges();
            }));
        }