static public async Task <byte[]> GetBinary(UCWAHref href) { if (href == null || string.IsNullOrEmpty(href.Href)) { return(null); } var uri = href.Href; if (!uri.StartsWith("http")) { uri = Settings.Host + uri; } using (HttpClient client = await GetClient(uri)) { var response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { return(await response.Content.ReadAsByteArrayAsync()); } else { await HandleError(response); } } return(null); }
static public async Task <T> Get <T>(UCWAHref href, CancellationToken cancellationToken, string version = defaultVersion, bool anonymous = false) where T : UCWAModelBase { if (href == null || string.IsNullOrEmpty(href.Href)) { return(default(T)); } return(await Get <T>(href.Href, cancellationToken, version, anonymous)); }
static public async Task <T> Post <T>(UCWAHref href, object body, CancellationToken cancellationToken, string version = defaultVersion, bool anonymous = false) { if (href == null || string.IsNullOrEmpty(href.Href)) { return(default(T)); } return(await Post <T>(href.Href, body, cancellationToken, version, anonymous)); }
static public async Task Delete(UCWAHref href, string version = "") { if (href == null || string.IsNullOrEmpty(href.Href)) { return; } await Delete(href.Href, version); }
static public async Task <T> Get <T>(UCWAHref href) where T : UCWAModelBase { if (href == null || string.IsNullOrEmpty(href.Href)) { return(default(T)); } return(await Get <T>(href.Href)); }
static public async Task <T> Put <T>(UCWAHref href, UCWAModelBase body, string version = "") { if (href == null || string.IsNullOrEmpty(href.Href)) { return(default(T)); } return(await Put <T>(href.Href, body, version)); }
static public async Task Put(UCWAHref href, UCWAModelBase body, string version = "") { if (href == null || string.IsNullOrEmpty(href.Href)) { return; } await Put(href.Href, body, version); }
static public async Task <T> Post <T>(UCWAHref href, object body, string version = "") { if (href == null || string.IsNullOrEmpty(href.Href)) { return(default(T)); } return(await Post <T>(href.Href, body)); }
static public async Task <string> Post(UCWAHref href, object body, string version = "") { if (href == null || string.IsNullOrEmpty(href.Href)) { return(""); } return(await Post(href.Href, body, version)); }
static public async Task <byte[]> GetBinary(UCWAHref href, CancellationToken cancellationToken, string version = defaultVersion, bool anonymous = false) { if (href == null || string.IsNullOrEmpty(href.Href)) { return(null); } var uri = EnsureUriContainsHttp(href.Href); return(await ExecuteHttpCallAndRetry((token) => GetInternal(uri, token, version, anonymous), async (response) => { return await response.Content.ReadAsByteArrayAsync(); }, cancellationToken)); }
static public Task <T> Get <T>(UCWAHref href, string version = defaultVersion, bool anonymous = false) where T : UCWAModelBase { return(Get <T>(href, GetNewCancellationToken(), version, anonymous)); }
static public Task <T> Post <T>(UCWAHref href, object body, string version = defaultVersion, bool anonymous = false) { return(Post <T>(href, body, GetNewCancellationToken(), version, anonymous)); }
static public Task <byte[]> GetBinary(UCWAHref href, string version = defaultVersion, bool anonymous = false) { return(GetBinary(href, GetNewCancellationToken(), version, anonymous)); }