GithubHelp home page GithubHelp logo

astrohart / xylogix.api.data.repositories Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 237 KB

(C#/x86-64/Class Library/VS2019) Acts as a Facade to the *.Api.Data.Iterators and *.Api.Data.Iterables projects' interfaces to then streamline and simply consumption of paged REST API data. Since we have to take care of considerations such as rate limit and choose-your-own-page-size, we have to take the Repository pattern and apply it to a REST API data set in view of said considerations. That's what this project strives to do.

C# 100.00%

xylogix.api.data.repositories's Introduction

xyLOGIX.Api.Data.Repositories class library

This class library project serves the following purposes:

  • Marry the concepts of accessing a REST API dataset of unknown length and iterating/paging through that data set;
  • The Repository data-access pattern from the N-Tier application world.

NOTE: This library merely specifies the framework for implementing this pattern; applications must refer to the libraries in this repo and the ones on which it depends, and then implement their own custom functionality to pull the data required and expose the actions listed below to clients.

That being said, the idea is, we are trying to build up a way to treat a REST API's paginated data as if it were a relational database table.

Each ApiRepository object, whose functionality is exposed by the IApiRepository interface, has the following actions (suppose T is the type of POCO that holds a single element of the dataset):

  • Attach(IIterable<T>) - Specify an IIterable<T> that can be used to access the underlying REST API dataset;
  • Delete(T) - If applicable (means, supported by the underlying REST API), will search for the item specified in the REST API's dataset and call on the API to delete its data from its own data sources;
  • DeleteAll(Predicate) - If applicable (means, supported by the underlying REST API), will use a Predicate to determine which elements of the underlying collection exposed by the REST API are to be removed from it;
  • Find(Predicate<T>) - If applicable (means, supported by the underlying REST API), iterates through the dataset provided by the API, element-by-element, testing each element against the supplied Predicate. A reference to the first occurrence of an element satisfying the conditions in the Predicate is returned.
  • Get(dynamic) - If supported by the underlying REST API, invokes the HTTP GET method necessary to simply pluck the desired element from the dataset directly, without doing any iteration. The parameter is left as dynamic so that arbitrary search parameters can be supplied.
  • GetAll basically implements a cursor that greedily consumes the entire REST API dataset -- however many elements may be -- across all available pages, and then returns an IEnumerable<T> on the entire collection. This does not use yield return and yield break -- you get the entire collection back all at once.
  • Update(T) - If applicable (means, supported by the underlying REST API), will use the values in the provided POCO instance to invoke HTTP POST on the REST API to update the element of the dataset that matches the values in T.

NOTE: Not all REST APIs are compatible with all of the actions listed above. Any methods listed above that are for an unsupported action are free to be implemented such that they throw NotSupportedException if called.

Clients of this library will not need to know the implementation details of how exactly data must be obtained from a REST API data set; they just have to treat the data set just like any other database table, say, that you might encounter in SQL Server or somesuch.

xylogix.api.data.repositories's People

Contributors

astrohart avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.