public static async Task <JToken> GetJsonAsync(this IWebRequestFactory factory, string endpoint, CancellationToken cancellationToken)
        {
            string result = await factory.GetStringAsync(endpoint, cancellationToken).ConfigureAwait(false);

            if (result == null)
            {
                return(null);
            }

            try
            {
                return(JToken.Parse(result));
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        private async Task <XDocument> ExecuteAutocompleteServiceQueryAsync(string endpoint, Func <string, string> query, CancellationToken cancellationToken)
        {
            if (endpoint == null)
            {
                return(null);
            }

            try
            {
                string location = query(endpoint);
                var    xml      = await _webRequestFactory.GetStringAsync(location, cancellationToken).ConfigureAwait(false);

                return(XDocument.Parse(xml));
            }
            catch (Exception)
            {
            }

            return(null);
        }