private async Task <ThingCollection> GetPartialThingsAsync( IList <ThingKey> partialThings) { IThingClient thingClient = Connection.CreateThingClient(); ThingQuery query = new ThingQuery(); foreach (ThingKey key in partialThings) { query.ItemKeys.Add(key); } // Need to copy the view from the original filter query.View = Query.View; query.States = Query.States; query.CurrentVersionOnly = Query.CurrentVersionOnly; if (Query.OrderByClauses.Count > 0) { foreach (var orderByClause in Query.OrderByClauses) { query.OrderByClauses.Add(orderByClause); } } ThingCollection results = await thingClient.GetThingsAsync(Record.Id, query).ConfigureAwait(false); return(results); }
internal ThingEnumerator( ThingCollection resultGroup) { _resultGroup = resultGroup; }
/// <summary> /// Constructs a <see cref="HealthRecordItemCollectionDebugView"/> with the specified /// <see cref="ThingCollection"/>. /// </summary> /// /// <param name="baseObject"> /// The object this class presents a view of for the debugger. /// </param> /// public HealthRecordItemCollectionDebugView(ThingCollection baseObject) { _baseObject = baseObject; }
private async Task GetPartialThingsAsync(int index) { // We must have a partial thing at this index. Get // the next MaxResultsPerRequest number of partial // items. List <ThingKey> partialThings = new List <ThingKey>(); for ( int partialThingIndex = index; (partialThings.Count < MaxResultsPerRequest || MaxResultsPerRequest == int.MinValue) && partialThingIndex < _abstractResults.Count; ++partialThingIndex) { var key = _abstractResults[partialThingIndex] as ThingKey; if (key != null) { partialThings.Add( key); } else { // We break if we hit something that is // not a Guid (like ThingBase). This means // that we will retrieve fewer things than // MaxResultsPerRequest but it will be simpler // to replace the partial things with the real // things. break; } } ThingCollection things = await GetPartialThingsAsync(partialThings).ConfigureAwait(false); bool atEndOfPartialThings = false; int newThingIndex = index; foreach (IThing thing in things) { // We need to start at the current index but look until // we find a matching thing ID. It is possible that the // thing may have been removed while holding on to the // partial thing ID from the original query. for (; newThingIndex < _abstractResults.Count; ++newThingIndex) { ThingKey abstractResultKey = _abstractResults[newThingIndex] as ThingKey; if (abstractResultKey != null) { if (abstractResultKey.Equals(thing.Key)) { // replace the partial thing with the real // thing _abstractResults[newThingIndex++] = thing; break; } } else { atEndOfPartialThings = true; break; } } if (atEndOfPartialThings) { break; } } }