Ejemplo n.º 1
0
 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);
     }
     ;
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
        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) { }
        }
Ejemplo n.º 5
0
 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);
Ejemplo n.º 6
0
        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;
                }
            }
        }
Ejemplo n.º 7
0
 public Task PullCurrentPageAsync(
     ApiConnectorCRUDBase <EntityT, KeyT> connector,
     Action <ConnectorRequest_GET <ApiConnectorCRUDBase <EntityT, KeyT> > >?config = null) =>
 PullPageAsync(PageIndex, connector, config);
Ejemplo n.º 8
0
 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);