Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

MediaHandler

Marco Siccardi edited this page Mar 16, 2018 · 2 revisions

To get a new instance, either create an inline variable or use your favorite Locator:

//inline var
var handler = new MediaHandler();

//MVVMLight (or any other Locator):
SimpleIoc.Default.Register<IMediaHandler>(()=> new MediaHandler());

If you want to add the "If-Modified-Since"-Header and "User-Agent"-Header, just fill in the parameters:

//inline var
var handler = new MediaHandler(DateTime.Now, "MyAwesomeApp", "1.0.0");

//MVVMLight (or any other Locator):
SimpleIoc.Default.Register<IMediaHandler>(()=> new MediaHandler(DateTime.Now, "MyAwesomeApp", "1.0.0"));

getting a list of media with default parameters:

var media = handler.GetMediaAsync("yourBaseUrl");

Note that you have optional parameters for pages, page counts, media type, mime type and order of the results.

get a single medium by its id:

var medium = handler.GetMediumAsync("yourBaseUrl", 12345);

All above calls will result in a WordPressEntitySet<TWordPressEntity> or a WordPressEntity<TWordPressEntity>. If there was an error on the API side, the Error property will be filled, otherwise it will be null and the Value will hold the result.

Clone this wiki locally