public RecordItem DeepClone() { string xml = this.Serialize(); if (string.IsNullOrEmpty(xml)) { return(null); } return(RecordItem.Deserialize(xml)); }
private ItemData EnsureItemData() { if (m_itemData == null) { var item = new RecordItem(); item.Type = new ItemType(m_typeID); m_itemData = new ItemData(m_typedData); item.Data = m_itemData; } return m_itemData; }
public static IAsyncOperation <ItemDataBlob> GetBlobDataAsync(IRecord record, ItemKey key) { if (record == null) { throw new ArgumentNullException("record"); } return(AsyncInfo.Run( async cancelToken => { RecordItem item = await record.GetItemAsync(key, ItemSectionType.Blobs).AsTask(cancelToken); return (item != null) ? item.BlobData : null; })); }
public RecordItem ShallowClone() { var item = new RecordItem(); item.Key = Key; item.Type = Type; item.State = State; item.Flags = Flags; item.EffectiveDate = EffectiveDate; item.Created = Created; item.Updated = Updated; item.m_data = m_data; item.m_blobs = m_blobs; return(item); }
public IAsyncAction RefreshBlobDataAsync(IRecord record) { if (record == null) { throw new ArgumentNullException("record"); } return(AsyncInfo.Run( async cancelToken => { RecordItem item = await record.GetItemAsync(Key, ItemSectionType.Blobs).AsTask(cancelToken); if (item != null) { m_blobs = item.m_blobs; } })); }
public RecordItem ShallowClone() { var item = new RecordItem(); item.Key = Key; item.Type = Type; item.State = State; item.Flags = Flags; item.EffectiveDate = EffectiveDate; item.Created = Created; item.Updated = Updated; item.m_data = m_data; item.m_blobs = m_blobs; return item; }
internal async Task<IList<ItemKey>> ExecutePutThingsAsync(CancellationToken cancelToken, RecordItem[] items) { items.ValidateRequired<RecordItem>("items"); ItemKeyList keyList = await Client.RecordMethods.PutThingsAsync<ItemKeyList>(m_recordRef, items, cancelToken); if (keyList == null || !keyList.HasKeys) { return null; } return keyList.Keys; }
public IAsyncOperation<ItemKey> NewItemAsync(RecordItem item) { if (item == null) { throw new ArgumentNullException("item"); } item.PrepareForNew(); return PutItemAsync(item); }
public IAsyncOperation<ItemKey> PutBlobInItem(RecordItem item, BlobInfo blobInfo, IInputStream source) { item.ValidateRequired("item"); return AsyncInfo.Run( async cancelToken => { Blob blob = await UploadBlob(blobInfo, source).AsTask(cancelToken); item.AddOrUpdateBlob(blob); return await UpdateItemAsync(item).AsTask(cancelToken); } ); }
public IAsyncOperation<ItemKey> PutItemAsync(RecordItem item) { if (item == null) { throw new ArgumentNullException("item"); } return AsyncInfo.Run( async cancelToken => { IList<ItemKey> keys = await ExecutePutThingsAsync(cancelToken, new[] {item}); return (keys != null) ? keys[0] : null; } ); }
public IAsyncOperation<IList<ItemKey>> PutMultipleAsync(IList<IItemDataTyped> data) { if (data == null) { throw new ArgumentNullException("data"); } var items = new RecordItem[data.Count]; for (int i = 0, count = data.Count; i < count; ++i) { items[0] = data[i].Item; } return PutItemsAsync(items); }
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); }); }
// // Will only write the item to the local store IF: // - Can take the write lock on the item (no pending edits in progress) // - There are no pending changes on the item // async Task SafePutItemInLocalStoreAsync(RecordItem item) { long lockID = m_itemLocks.AcquireLock(item.ID); if (!RecordItemLockTable.IsValidLockID(lockID)) { return; // Item is locked for editing. Don't overrwrite yet } try { // Make sure there are no pending updates if (!await m_changeManager.HasChangesForItemAsync(item.ID)) { await m_localStore.PutItemAsync(item); } } finally { m_itemLocks.SafeReleaseLock(item.ID, lockID); } }
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); } } }); }
async Task AddKeyAsync(RecordItem addedItem) { ViewKey viewKey = ViewKey.FromItem(addedItem); using (await CrossThreadLockScope.Enter(m_lock)) { m_items.Keys.Add(viewKey); await this.SaveView(); } }
void ValidateItem(RecordItem item) { item.Type.ValidateRequired("Type"); item.Key.ValidateRequired("Key"); }
// SynchronizedStore calls this to track "Put"s internal async Task TrackPutAsync(RecordItem item) { this.ValidateItem(item); await m_changeTable.TrackChangeAsync(item.Type.ID, item.Key, RecordItemChangeType.Put); }
async Task PutItemInStore(RecordItem item) { await m_objectStore.PutAsync(item.Key.ID, item); }
public IAsyncAction PutItemAsync(RecordItem item) { if (item == null) { throw new ArgumentNullException("item"); } item.Key.ValidateRequired("Key"); return AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { await this.PutItemInStore(item); } }); }
async Task UpdateKeyAsync(string itemID, RecordItem updatedItem) { ViewKey viewKey = ViewKey.FromItem(updatedItem); using (await CrossThreadLockScope.Enter(m_lock)) { m_items.Keys.UpdateKey(itemID, viewKey); await this.SaveView(); } }
public static void PrepareForNew(RecordItem item) { if (item == null) { throw new ArgumentNullException("item"); } item.Key = ItemKey.NewLocalKey(); // A special "Local only" Key item.UpdateEffectiveDate(); }