protected async Task PullPreviousPageAsync( ApiConnectorCRUDBase <EntityT, KeyT> connector, Action <ConnectorRequest_GET <ApiConnectorCRUDBase <EntityT, KeyT> > >?config = null) { if (HasPreviousPage) { PageIndex--; await PullPageAsync(PageIndex, connector, config).ConfigureAwait(false); } ; }
public static RestEntity <EntityT, KeyT>?AssignRest <EntityT, KeyT>( this RestEntity <EntityT, KeyT>?entity, ApiConnectorCRUDBase <EntityT, KeyT> conn) where EntityT : class, IEntity <EntityT, KeyT> where KeyT : IEquatable <KeyT>, IComparable, new() { if (entity != null) { entity.ConnectorService = conn.ConnectorService; entity.ConnectorCRUD = conn; } return(entity); }
public static IEnumerable <RestEntity <EntityT, KeyT> >?AssignRest <EntityT, KeyT>( this IEnumerable <RestEntity <EntityT, KeyT> >?entities, ApiConnectorCRUDBase <EntityT, KeyT> conn) where EntityT : class, IEntity <EntityT, KeyT> where KeyT : IEquatable <KeyT>, IComparable, new() { if (entities != null) { foreach (var entity in entities) { entity.ConnectorService = conn.ConnectorService; entity.ConnectorCRUD = conn; } } return(entities); }
protected async Task PullPageAsync( int page, ApiConnectorCRUDBase <EntityT, KeyT> connector, Action <ConnectorRequest_GET <ApiConnectorCRUDBase <EntityT, KeyT> > >?config = null) { CancellationTokenSource.Cancel(); CancellationTokenSource = new CancellationTokenSource(); try { EntityDownloadStart?.Invoke(this, new EventArgs()); IPaginatedList <EntityT, KeyT>?paginator = await GetPaginatorAsync( connector, config, page, CancellationTokenSource.Token).ConfigureAwait(false); await UpdatePaginatorAsync(paginator).ConfigureAwait(false); EntityDownloadFinish?.Invoke(this, new EventArgs()); } catch (TaskCanceledException) { } }
public override async Task <IPaginatedList <EntityT, KeyT>?> GetPaginatorAsync( ApiConnectorCRUDBase <EntityT, KeyT> connector, Action <ConnectorRequest_GET <ApiConnectorCRUDBase <EntityT, KeyT> > >?config = null, int?page = null, CancellationToken cancellationToken = default) => await connector.GetAsync(config, page : page, cancellationToken : cancellationToken).ConfigureAwait(false);
public virtual async IAsyncEnumerable <IPaginatedList <EntityT, KeyT> > PullAllPagesAsync(ApiConnectorCRUDBase <EntityT, KeyT> connector) { CancellationTokenSource cts = new(); var cancellationToken = cts.Token; for (int page_i = 1; page_i <= TotalPages; page_i++) { IPaginatedList <EntityT, KeyT>?paginator = await GetPaginatorAsync( connector, page : page_i, cancellationToken : cancellationToken).ConfigureAwait(false); if (paginator != null) { yield return(paginator); } else { yield break; } } }
public Task PullCurrentPageAsync( ApiConnectorCRUDBase <EntityT, KeyT> connector, Action <ConnectorRequest_GET <ApiConnectorCRUDBase <EntityT, KeyT> > >?config = null) => PullPageAsync(PageIndex, connector, config);
public abstract Task <IPaginatedList <EntityT, KeyT>?> GetPaginatorAsync( ApiConnectorCRUDBase <EntityT, KeyT> connector, Action <ConnectorRequest_GET <ApiConnectorCRUDBase <EntityT, KeyT> > >?config = null, int?page = null, CancellationToken cancellationToken = default);