sdk/dotnet/test/Datasync.Common.Test/Mocks/MockOfflineStore.cs
/// <summary>
/// Returns items from the table.
/// </summary>
/// <param name="query">A query describing the items to be returned.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
/// <returns>A task that returns a page of items when complete.</returns>
Returns items from the table.
Returns items from the table .
public Task<Page<JObject>> GetPageAsync(QueryDescription query, CancellationToken cancellationToken = default)
        {
            var table = GetOrCreateTable(query.TableName);
            IEnumerable<JObject> items;
            if (query.TableName == SystemTables.OperationsQueue)
            {
                items = FilterItemList(query, table.Values);
            }
            else if (ReadAsyncFunc != null)
            {
                items = ReadAsyncFunc(query);
            }
            else if (ReadResponses.Count > 0)
            {
                var arr = JArray.Parse(ReadResponses.Dequeue());
                items = (IEnumerable<JObject>)arr.ToArray();
            }
            else if (ReadPageFunc != null)
            {
                return Task.FromResult(ReadPageFunc.Invoke(query));
            }
            else
            {
                items = table.Values;
            }
            if (query.IncludeTotalCount)
            {
                return Task.FromResult(new Page<JObject> { Count = items.Count(), Items = items });
            }
            else
            {
                return Task.FromResult(new Page<JObject> { Items = items });
            }
        }
public Task < Page < JObject > > GetPageAsync ( QueryDescription query , CancellationToken cancellationToken = default ) { var table = GetOrCreateTable ( query . TableName ) ; IEnumerable < JObject > items ; if ( query . TableName == SystemTables . OperationsQueue ) { items = FilterItemList ( query , table . Values ) ; } else if ( ReadAsyncFunc != null ) { items = ReadAsyncFunc ( query ) ; } else if ( ReadResponses . Count > 0 ) { var arr = JArray . Parse ( ReadResponses . Dequeue ( ) ) ; items = ( IEnumerable < JObject > ) arr . ToArray ( ) ; } else if ( ReadPageFunc != null ) { return Task . FromResult ( ReadPageFunc . Invoke ( query ) ) ; } else { items = table . Values ; } if ( query . IncludeTotalCount ) { return Task . FromResult ( new Page < JObject > { Count = items . Count ( ) , Items = items } ) ; } else { return Task . FromResult ( new Page < JObject > { Items = items } ) ; } }
Returns items from the table.
Returns items from the table .
// Handle the operations queue.
A task that returns a page of items when complete.
A task that returns a page of items when complete .
query
QueryDescription
A query describing the items to be returned.
A query describing the items to be returned .
cancellationToken
CancellationToken
A  to observe.
A to observe .