Пример #1
0
        public SynchronizedView CreateView(string viewName, ItemQuery query)
        {
            if (string.IsNullOrEmpty(viewName))
            {
                throw new ArgumentException("viewName");
            }

            return new SynchronizedView(m_dataStore, query, viewName);
        }
        //------------------------------------------------------------------
        //
        // Factory methods
        // Constructor overloading in WinRT is limited
        //
        //------------------------------------------------------------------
        public static ItemQuery QueryForTypeID(string typeID)
        {
            var query = new ItemQuery();

            query.Name = typeID;
            query.Filters.Add(ItemFilter.FilterForType(typeID));
            query.View.TypeVersions.Add(typeID);

            return(query);
        }
        public static ItemQuery QueryForKeys(IEnumerable <ItemKey> keys)
        {
            if (keys == null)
            {
                throw new ArgumentNullException("keys");
            }

            var query = new ItemQuery();

            query.Keys = keys.ToArray();

            return(query);
        }
        public static ItemQuery QueryForKey(ItemKey key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            var query = new ItemQuery();

            query.Keys = new[] { key };

            return(query);
        }
Пример #5
0
        public ItemDataTypedList ToItemDataTypedList(IRecord record, ItemQuery originalQuery)
        {
            if (record == null)
            {
                throw new ArgumentNullException("record");
            }
            if (originalQuery == null)
            {
                throw new ArgumentNullException("originalQuery");
            }

            return(new ItemDataTypedList(record, originalQuery.View, Items, PendingKeys));
        }
        public ViewData(ItemQuery query, string name) : this()
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("name");
            }

            Query = query;
            Name = name;
        }
        public static ItemQuery QueryForKeys(IList <ItemFilter> filters, int maxResults)
        {
            filters.ValidateRequired("filter");

            var query = new ItemQuery();

            query.View.SetSections(ItemSectionType.Core);
            query.Filters.AddRange(filters);
            query.MaxFullItems = new NonNegativeInt(0);
            if (maxResults > 0)
            {
                query.MaxResults = new NonNegativeInt(maxResults);
            }

            return(query);
        }
Пример #8
0
        public IAsyncOperation<ItemDataTypedList> GetAsync(ItemQuery query)
        {
            query.ValidateRequired("query");
            //
            // Ensure the user is querying for typed information
            //
            if (!query.View.ReturnsTypedData)
            {
                throw new ArgumentException("query");
            }

            return AsyncInfo.Run(
                async cancelToken =>
                      {
                          ItemQueryResult[] results = await ExecuteQueriesAsync(cancelToken, new[] {query});
                          if (results.IsNullOrEmpty())
                          {
                              return null;
                          }

                          ItemQueryResult result = results[0];
                          return new ItemDataTypedList(this, query.View, result.Items, result.PendingKeys);
                      });
        }
Пример #9
0
        public static ItemQuery QueryForKeys(IEnumerable<ItemKey> keys)
        {
            if (keys == null)
            {
                throw new ArgumentNullException("keys");
            }

            var query = new ItemQuery();
            query.Keys = keys.ToArray();

            return query;
        }
Пример #10
0
        public static ItemQuery QueryForKey(ItemKey key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            var query = new ItemQuery();
            query.Keys = new[] {key};

            return query;
        }
Пример #11
0
        internal async Task<ItemQueryResult[]> ExecuteQueriesAsync(CancellationToken cancelToken, ItemQuery[] queries)
        {
            queries.ValidateRequired<ItemQuery>("queries");

            RecordQueryResponse queryResponse =
                await Client.RecordMethods.GetThingsAsync<RecordQueryResponse>(m_recordRef, queries, cancelToken);
            return queryResponse.Results;
        }
Пример #12
0
        internal async Task<IList<RecordItem>> GetAllItemsAsync(CancellationToken cancelToken, ItemQuery query)
        {
            var itemsFound = new List<RecordItem>();
            while (true)
            {
                ItemQueryResult[] results = await ExecuteQueriesAsync(cancelToken, new[] {query});
                if (results.IsNullOrEmpty())
                {
                    break;
                }

                ItemQueryResult result = results[0];
                if (result.HasItems)
                {
                    itemsFound.AddRange(result.Items);
                }
                if (!result.HasPending)
                {
                    break;
                }
                //
                // Issue a fresh query for pending items
                //
                ItemQuery pendingQuery = ItemQuery.QueryForPending(result.PendingItems);
                pendingQuery.View = query.View;
                query = pendingQuery;
            }

            return itemsFound;
        }
Пример #13
0
 public IAsyncOperation<IList<RecordItem>> GetAllItemsAsync(ItemQuery query)
 {
     return AsyncInfo.Run(cancelToken => GetAllItemsAsync(cancelToken, query));
 }
Пример #14
0
 public IAsyncOperation<ItemQueryResult> GetItemsAsync(ItemQuery query)
 {
     return AsyncInfo.Run(
         async cancelToken =>
               {
                   ItemQueryResult[] results = await ExecuteQueriesAsync(cancelToken, new[] {query});
                   return (results.IsNullOrEmpty()) ? null : results[0];
               });
 }
        public ItemDataTypedList ToItemDataTypedList(IRecord record, ItemQuery originalQuery)
        {
            if (record == null)
            {
                throw new ArgumentNullException("record");
            }
            if (originalQuery == null)
            {
                throw new ArgumentNullException("originalQuery");
            }

            return new ItemDataTypedList(record, originalQuery.View, Items, PendingKeys);
        }
Пример #16
0
 public ViewData(ItemQuery query)
     : this(query, query.Name)
 {
 }
Пример #17
0
        public static ItemQuery QueryForKeys(IList<ItemFilter> filters, int maxResults)
        {
            filters.ValidateRequired("filter");

            var query = new ItemQuery();
            query.View.SetSections(ItemSectionType.Core);
            query.Filters.AddRange(filters);
            query.MaxFullItems = new NonNegativeInt(0);
            if (maxResults > 0)
            {
                query.MaxResults = new NonNegativeInt(maxResults);
            }

            return query;
        }
Пример #18
0
 public SynchronizedView CreateView(ItemQuery query)
 {
     return new SynchronizedView(m_dataStore, query, query.Name);
 }
 public IAsyncOperation<IList<RecordItem>> GetAllItemsAsync(ItemQuery query)
 {
     return m_record.GetAllItemsAsync(query);
 }
 public IAsyncOperation<IList<RecordItem>> GetAllItemsAsync(ItemQuery query)
 {
     this.ProduceError();
     return m_innerStore.GetAllItemsAsync(query);
 }
        async Task<IList<RecordItem>> LookupCommitsInRemoteStoreAsync(params string[] changeIDs)
        {
            ItemQuery query = new ItemQuery();
            query.View.SetSections(ItemSectionType.Core);
            query.MaxFullItems = new NonNegativeInt(0);
            query.MaxResults = new NonNegativeInt(changeIDs.Length);
            query.ClientIDs = changeIDs.ToArray();

            return await m_store.RemoteStore.GetAllItemsAsync(query);
        }
Пример #22
0
        //------------------------------------------------------------------
        //
        // Factory methods
        // Constructor overloading in WinRT is limited
        //
        //------------------------------------------------------------------
        public static ItemQuery QueryForTypeID(string typeID)
        {
            var query = new ItemQuery();
            query.Name = typeID;
            query.Filters.Add(ItemFilter.FilterForType(typeID));
            query.View.TypeVersions.Add(typeID);

            return query;
        }
Пример #23
0
 public SynchronizedView(SynchronizedStore store, ItemQuery query, string name)
     : this(store, new ViewData(query, name))
 {
 }