-
Notifications
You must be signed in to change notification settings - Fork 1
Structure
Even though the structure is not that complicated and all methods are fully commented, it is quite helpful to understand it before using it.
The library uses handlers for getting the different entitiy types from the WordPress API. All handlers are derived from the BaseHandler
class, which provides two methods:
public HttpClient SetupClient(DateTime? modifiedSince = null, string userAgent = null, string version = null)
public void SetUserAgent(HttpClient client, string userAgent, string version)
All derived handlers call into the SetupClient
method to set up the HttpClient
with the "If-Modified-Since"-Header and the "User-Agent"-Header, if values are provided. The SetUserAgent
method allows you to modify the "User-Agent"-Header of an existing HttpClient
.
In our MVVM-driven world, we often use Locators. You can either create new instances directly or register the interface with your Locator:
//example: MVVMLight SimpleIoc registration:
SimpleIoc.Default.Register<IPostsHandler>(()=> new PostsHandler(null, "MyAwesomeApp", "1.0.0"));
//example: direct instance creation:
var postsHandler = new PostsHandler(null, "MyAwesomeApp", "1.0.0")
WordPressReader Standard converts the raw json-responses into WordPressEntity
-Models. There are two types:
-
WordPressEntity<TWordPressEntity>
: used for single WordPressEntities, e.g. a single post -
WordPressEntitySet<TWordPressEntity>
: used for lists of WordPressEntities, e.g. a list of posts
Both Model types also provide the raw json string as well as an Error
property. Use the Raw
property to create your own models or for caching purposes.
Because of their generic implementation, WordPressEntities can easily be used to match your WordPress models (which may differ from the standard implementation this library provides). If you need a Handler
for different endpoint, you can easily create one by deriving from the BaseHandler
class.