public IAsyncAction RemoveAsync(VocabIdentifier vocabID)
        {
            if (vocabID == null)
            {
                throw new ArgumentNullException("vocabID");
            }

            return m_root.Store.DeleteAsync(vocabID.GetKey()).AsAsyncAction();
        }
        public IAsyncOperation<VocabCodeSet> GetAsync(VocabIdentifier vocabID)
        {
            if (vocabID == null)
            {
                throw new ArgumentNullException("vocabID");
            }

            return GetVocabAsync(vocabID).AsAsyncOperation();
        }
 public IAsyncAction PutAsync(VocabIdentifier vocabID, VocabCodeSet vocab)
 {
     if (vocabID == null)
     {
         throw new ArgumentNullException("vocabID");
     }
     if (vocab == null)
     {
         throw new ArgumentNullException("vocab");
     }
     string key = vocabID.GetKey();
     return m_root.Store.PutAsync(key, vocab).AsAsyncAction();
 }
Esempio n. 4
0
        public IAsyncOperation<VocabQueryResult> SearchAsync(VocabIdentifier vocab, string searchText)
        {
            vocab.ValidateRequired("vocab");

            return AsyncInfo.Run(
                async cancelToken =>
                      {
                          //VocabQuery query = new VocabQuery(vocab, searchText);
                          var query = new object[]
                                      {
                                          vocab,
                                          new VocabSearch(searchText)
                                      };
                          VocabQueryResults results =
                              await m_app.Client.ServiceMethods.SearchVocabulary<VocabQueryResults>(query, cancelToken);

                          return results.HasMatches ? results.Matches : null;
                      });
        }
 private async Task EnsureVocabImplAsync(VocabIdentifier vocabID, TimeSpan maxAge)
 {
     bool isStale = await IsStale(vocabID, maxAge);
     if (isStale)
     {
         await DownloadVocabs(new[] {vocabID});
     }
 }
        private async Task<bool> IsStale(VocabIdentifier vocabID, TimeSpan maxAge)
        {
            DateTimeOffset dt = await m_root.Store.GetUpdateDateAsync(vocabID.GetKey());
            TimeSpan offset = DateTimeOffset.Now.Subtract(dt);

            return (offset >= maxAge);
        }
 private async Task<VocabCodeSet> GetVocabAsync(VocabIdentifier vocabID)
 {
     string key = vocabID.GetKey();
     return (VocabCodeSet) await m_root.Store.GetAsync(key, typeof (VocabCodeSet));
 }
 /// <summary>
 /// If vocabs are not available, will kick off a fetch in the background
 /// </summary>
 public IAsyncAction EnsureVocabAsync(VocabIdentifier vocabID, int maxAgeSeconds)
 {
     return Task.Run(() => EnsureVocabImplAsync(vocabID, TimeSpan.FromSeconds(maxAgeSeconds))).AsAsyncAction();
 }