internal IAsyncAction RemoveAsync(ItemKey key, RecordItemLock itemLock)
        {
            key.ValidateRequired("key");

            return AsyncInfo.Run(async cancelToken =>
            {
                await this.Data.RemoveItemAsync(m_typeID, key, itemLock);
                await this.RemoveKeyAsync(key);
            });
        }
        internal async Task<RecordItemEditOperation> OpenForEditAsync(ItemKey key, RecordItemLock itemLock)
        {
            IItemDataTyped data = await this.EnsureItemAvailableAndGetByKeyAsync(key);
            if (data == null)
            {
                return null;
            }

            return new RecordItemEditOperation(this, data, itemLock);
        }
        internal IAsyncAction PutAsync(IItemDataTyped item, RecordItemLock itemLock)
        {
            this.ValidateItem(item);

            return AsyncInfo.Run(async cancelToken => {            
                await this.Data.PutAsync(item, itemLock);
                await this.UpdateKeyAsync(item.Item);
            });
        }
        void Dispose(bool fromDispose)
        {
            if (fromDispose)
            {
                this.ReleaseLock();
                GC.SuppressFinalize(this);
            }

            m_rLock = null;
        }
 void ReleaseLock()
 {
     if (m_rLock != null)
     {
         m_rLock.Release();
         m_rLock = null;
     }
 }
 internal RecordItemEditOperation(SynchronizedType sType, IItemDataTyped data, RecordItemLock rLock)
 {
     m_sType = sType;
     m_rLock = rLock;
     m_data = data.Item.DeepClone().TypedData;
 }
        /// <summary>
        /// Remove an item. To remove, you must first acquire a lock on the item, and prove that you own the lock.
        /// If you use the higher level SychronizedType object, you won't have to acquire the lock yourself
        /// </summary>
        public IAsyncAction RemoveItemAsync(string typeID, ItemKey itemKey, RecordItemLock itemLock)
        {
            itemKey.ValidateRequired("key");
            if (itemLock == null)
            {
                throw new ArgumentNullException("itemLock");
            }

            m_itemLocks.ValidateLock(itemKey.ID, itemLock.LockID);

            return AsyncInfo.Run(async cancelToken => {                
                await m_localStore.RemoveItemAsync(itemKey);
                await m_changeManager.TrackRemoveAsync(typeID, itemKey);                
            });
        }        
        public IAsyncAction PutItemAsync(RecordItem item, RecordItemLock itemLock)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (itemLock == null)
            {
                throw new ArgumentNullException("itemLock");
            }

            m_itemLocks.ValidateLock(item.ID, itemLock.LockID);
            
            item.UpdateEffectiveDate();

            return AsyncInfo.Run(async cancelToken => {
                await m_localStore.PutItemAsync(item);
                await m_changeManager.TrackPutAsync(item);
            });
        }
 /// <summary>
 /// Updates an existing item. To update, you must first acquire a lock on it, and prove that you own the lock. 
 /// Note: if you use higher level objects like SynchronizedStore, you won't have to acquire locks yourself. 
 /// </summary>
 public IAsyncAction PutAsync(IItemDataTyped item, RecordItemLock itemLock)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     return this.PutItemAsync(item.Item, itemLock);
 }
        internal RecordItemLock AcquireItemLock(string itemID)
        {
            long lockID = 0;
            try
            {
                lockID = this.AcquireLock(itemID);
                if (!IsValidLockID(lockID))
                {
                    return null;
                }

                RecordItemLock itemLock = new RecordItemLock(this, itemID, lockID);
                lockID = 0;
                return itemLock;
            }
            finally
            {
                if (IsValidLockID(lockID))
                {
                    this.ReleaseLock(itemID, lockID);
                }
            }
        }