internal async Task <StoredQuery> GetStoredQueryAsyncImpl(string queryKey)
 {
     using (await CrossThreadLockScope.Enter(m_metadataLock))
     {
         return((StoredQuery)await m_metadataStore.Store.GetAsync(queryKey, typeof(StoredQuery)));
     }
 }
コード例 #2
0
        // Get ids of items that changed for a given type ID
        public IAsyncOperation <IList <string> > GetIDsOfChangedItemsForTypeAsync(string typeID)
        {
            if (string.IsNullOrEmpty(typeID))
            {
                throw new ArgumentException("typeID");
            }

            return(AsyncInfo.Run(async cancelToken =>
            {
                List <string> ids = new List <string>();
                using (await CrossThreadLockScope.Enter(m_lock))
                {
                    await this.EnsureIndexAsync();
                    foreach (string itemID in m_itemIDIndex)
                    {
                        RecordItemChange change = await this.GetChangeAsync(itemID);
                        if (change != null && change.IsChangeForType(typeID))
                        {
                            ids.Add(itemID);
                        }
                    }

                    return (IList <string>)ids;
                }
            }));
        }
コード例 #3
0
        async Task <SynchronizedType> Ensure(string typeID, CancellationToken cancelToken)
        {
            using (await CrossThreadLockScope.Enter(m_lock))
            {
                WeakReference <SynchronizedType> viewRef = null;
                SynchronizedType view = null;
                if (m_views.TryGetValue(typeID, out viewRef))
                {
                    viewRef.TryGetTarget(out view);
                }
                if (view != null)
                {
                    return(view);
                }

                view = new SynchronizedType(this, typeID);
                await view.Load();

                if (viewRef == null)
                {
                    viewRef = new WeakReference <SynchronizedType>(view);
                }
                else
                {
                    viewRef.SetTarget(view);
                }
                m_views[typeID] = viewRef;
                return(view);
            }
        }
コード例 #4
0
        // Are there any changes for the given type ID?
        public IAsyncOperation <bool> HasChangesForTypeAsync(string typeID)
        {
            if (string.IsNullOrEmpty(typeID))
            {
                throw new ArgumentException("typeID");
            }

            return(AsyncInfo.Run(async cancelToken =>
            {
                using (await CrossThreadLockScope.Enter(m_lock))
                {
                    await this.EnsureIndexAsync();
                    foreach (string itemID in m_itemIDIndex)
                    {
                        RecordItemChange change = await this.GetChangeAsync(itemID);
                        if (change != null && change.IsChangeForType(typeID))
                        {
                            return true;
                        }
                    }

                    return false;
                }
            }));
        }
 internal async Task PutViewAsync(SynchronizedView view, CancellationToken cancelToken)
 {
     using (await CrossThreadLockScope.Enter(m_metadataLock))
     {
         await m_metadataStore.PutAsync(MakeViewKey(view.Name), view.Data);
     }
 }
 internal async Task <RecordItem> GetItemByIDAsyncImpl(string itemID)
 {
     using (await CrossThreadLockScope.Enter(m_lock))
     {
         return(await this.GetItemFromStore(itemID));
     }
 }
コード例 #7
0
 async Task RemoveKeyAsync(ItemKey key)
 {
     using (await CrossThreadLockScope.Enter(m_lock))
     {
         m_items.Keys.RemoveByItemKey(key);
         await this.SaveView();
     }
 }
 async Task DeleteStorageForRecordAsync(string recordID)
 {
     using (await CrossThreadLockScope.Enter(m_storageLock))
     {
         System.Diagnostics.Debug.WriteLine("Deleting storage for {0}", recordID);
         await m_root.DeleteChildStoreAsync(recordID);
     }
 }
コード例 #9
0
 public IAsyncAction SaveAsync()
 {
     return(AsyncInfo.Run(async cancelToken => {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             await this.SaveView();
         }
     }));
 }
 internal async Task PutItemsAsyncImpl(IEnumerable <RecordItem> items)
 {
     using (await CrossThreadLockScope.Enter(m_lock))
     {
         foreach (RecordItem item in items)
         {
             await this.PutItemInStore(item);
         }
     }
 }
コード例 #11
0
 // Returns all changes registered with the change table
 public IAsyncOperation <IList <RecordItemChange> > GetChangesAsync()
 {
     return(AsyncInfo.Run(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             return (IList <RecordItemChange>)await this.GetAllChangesAsync();
         }
     }));
 }
コード例 #12
0
        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();
            }
        }
コード例 #13
0
        async Task AddKeyAsync(RecordItem addedItem)
        {
            ViewKey viewKey = ViewKey.FromItem(addedItem);

            using (await CrossThreadLockScope.Enter(m_lock))
            {
                m_items.Keys.Add(viewKey);
                await this.SaveView();
            }
        }
コード例 #14
0
 public IAsyncOperation <IList <IItemDataTyped> > EnsureItemsAvailableAndGetAsync(int startAt, int count)
 {
     return(AsyncInfo.Run(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             return await m_items.GetItemsAsync(startAt, count, true, cancelToken);
         }
     }));
 }
 public IAsyncOperation <IList <string> > GetItemIDsAsync()
 {
     return(AsyncInfo.Run(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             return await m_objectStore.GetAllKeysAsync();
         }
     }));
 }
コード例 #16
0
 public IAsyncOperation <IItemDataTyped> EnsureItemAvailableAndGetAsync(int index)
 {
     return(AsyncInfo.Run(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             return await m_items.GetItemAsync(index, true, cancelToken);
         }
     }));
 }
コード例 #17
0
 public IAsyncOperation <IList <ItemKey> > GetKeysForItemsNeedingDownload(int startAt, int count)
 {
     return(AsyncInfo.Run <IList <ItemKey> >(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             return await m_items.GetKeysForItemsNeedingDownload(startAt, count);
         }
     }));
 }
コード例 #18
0
 public IAsyncOperation <IItemDataTyped> GetLocalItemByKeyAsync(ItemKey key)
 {
     return(AsyncInfo.Run(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             return await m_items.GetLocalItemByKeyAsync(key);
         }
     }));
 }
 public IAsyncAction DeleteStoredQueryAsync(string name)
 {
     return(AsyncInfo.Run(
                async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_metadataLock))
         {
             await m_metadataStore.DeleteAsync(MakeStoredQueryKey(name));
         }
     }));
 }
コード例 #20
0
 // Return the # of pending changes
 public IAsyncOperation <int> GetChangeCountAsync()
 {
     return(AsyncInfo.Run(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             await this.EnsureIndexAsync();
             return (m_itemIDIndex.Count);
         }
     }));
 }
        public IAsyncAction RemoveItemAsync(ItemKey key)
        {
            key.ValidateRequired("key");

            return(AsyncInfo.Run(async cancelToken =>
            {
                using (await CrossThreadLockScope.Enter(m_lock))
                {
                    await m_objectStore.DeleteAsync(key.ID);
                }
            }));
        }
コード例 #22
0
 // Return Ids of items that changed
 public IAsyncOperation <IList <string> > GetIDsOfChangedItemsAsync()
 {
     return(AsyncInfo.Run(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             await this.EnsureIndexAsync();
             List <string> itemIDs = m_itemIDIndex.ToList();
             return (IList <string>)itemIDs;
         }
     }));
 }
コード例 #23
0
 // PredicateDelegate is passed IItemDataTyped objects
 public IAsyncOperation <IList <IItemDataTyped> > SelectAsync(PredicateDelegate predicate)
 {
     if (predicate == null)
     {
         throw new ArgumentNullException("predicate");
     }
     return(AsyncInfo.Run(async cancelToken => {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             return await m_items.SelectAsync(predicate, cancelToken);
         }
     }));
 }
コード例 #24
0
 // Gets the current change information for the given itemID
 public IAsyncOperation <RecordItemChange> GetChangeForItemAsync(string itemID)
 {
     if (string.IsNullOrEmpty(itemID))
     {
         throw new ArgumentException("itemID");
     }
     return(AsyncInfo.Run(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             return await this.GetChangeAsync(itemID);
         }
     }));
 }
コード例 #25
0
 public IAsyncOperation <IItemDataTyped> EnsureItemAvailableAndGetByKeyAsync(ItemKey key)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     return(AsyncInfo.Run(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             return await m_items.GetItemByKeyAsync(key, true, cancelToken);
         }
     }));
 }
コード例 #26
0
 // Remove changes for the given item ID
 public IAsyncAction RemoveChangeAsync(string itemID)
 {
     if (string.IsNullOrEmpty(itemID))
     {
         throw new ArgumentException("itemID");
     }
     return(AsyncInfo.Run(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             await this.DeleteChangeAsync(itemID);
         }
     }));
 }
        public IAsyncOperation <DateTimeOffset> UpdateDateForAsync(ItemKey key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            return(AsyncInfo.Run(async cancelToken =>
            {
                using (await CrossThreadLockScope.Enter(m_lock))
                {
                    return await m_objectStore.GetUpdateDateAsync(key.ID);
                }
            }));
        }
コード例 #28
0
 // Remove all changes
 public IAsyncAction RemoveAllChangesAsync()
 {
     return(AsyncInfo.Run(async cancelToken =>
     {
         using (await CrossThreadLockScope.Enter(m_lock))
         {
             await this.EnsureIndexAsync();
             string[] allIDs = m_itemIDIndex.ToArray();
             foreach (string itemID in allIDs)
             {
                 await this.DeleteChangeAsync(itemID);
             }
         }
     }));
 }
コード例 #29
0
        /// <summary>
        /// Synchronize --> update the list of known Items by fetching a fresh list of ItemKeys from HealthVault
        ///
        /// If there are pending changes (writes, removes) that have not been committed to HealthVault yet, synchronize will do nothing
        /// and return false.
        ///
        /// </summary>
        /// <returns>FALSE if there are pending changes that have not yet been committed to HealthVault</returns>
        public IAsyncOperation <bool> SynchronizeAsync()
        {
            return(AsyncInfo.Run <bool>(async cancelToken => {
                if (await this.Data.Changes.HasChangesForTypeAsync(m_typeID))
                {
                    return false;
                }

                using (await CrossThreadLockScope.Enter(m_lock))
                {
                    await m_items.SynchronizeAsyncImpl(cancelToken);
                    await this.SaveView();
                    return true;
                }
            }));
        }
コード例 #30
0
        // Are there any changes pending for the given item ID
        public IAsyncOperation <bool> HasChangesForItemAsync(string itemID)
        {
            if (string.IsNullOrEmpty(itemID))
            {
                throw new ArgumentException("itemID");
            }

            return(AsyncInfo.Run(async cancelToken =>
            {
                using (await CrossThreadLockScope.Enter(m_lock))
                {
                    await this.EnsureIndexAsync();
                    return m_itemIDIndex.Contains(itemID);
                }
            }));
        }