예제 #1
0
        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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        static public async Task Delete(UCWAHref href, string version = "")
        {
            if (href == null || string.IsNullOrEmpty(href.Href))
            {
                return;
            }

            await Delete(href.Href, version);
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }
예제 #7
0
        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);
        }
예제 #8
0
        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));
        }
예제 #9
0
        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));
        }
예제 #10
0
        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));
        }
예제 #11
0
 static public Task <T> Get <T>(UCWAHref href, string version = defaultVersion, bool anonymous = false) where T : UCWAModelBase
 {
     return(Get <T>(href, GetNewCancellationToken(), version, anonymous));
 }
예제 #12
0
 static public Task <T> Post <T>(UCWAHref href, object body, string version = defaultVersion, bool anonymous = false)
 {
     return(Post <T>(href, body, GetNewCancellationToken(), version, anonymous));
 }
예제 #13
0
 static public Task <byte[]> GetBinary(UCWAHref href, string version = defaultVersion, bool anonymous = false)
 {
     return(GetBinary(href, GetNewCancellationToken(), version, anonymous));
 }