Exemple #1
0
        /// <summary>
        /// Creates an instance with the specified settings.
        /// </summary>
        protected HttpClientService(HttpClientServiceSettings settings, Uri defaultBaseUri)
        {
            settings = settings ?? new HttpClientServiceSettings();

            m_httpClient  = settings.HttpClient ?? s_defaultHttpClient;
            m_aspects     = settings.Aspects;
            m_synchronous = settings.Synchronous;

            var baseUri = settings.BaseUri ?? defaultBaseUri;

            m_baseUrl = baseUri == null ? "" : (baseUri.IsAbsoluteUri ? baseUri.AbsoluteUri : baseUri.OriginalString);

            ContentSerializer = settings.ContentSerializer ?? JsonHttpContentSerializer.Instance;
        }
        /// <summary>
        /// Creates an instance with the specified settings.
        /// </summary>
        protected HttpClientService(HttpClientServiceSettings settings, Uri defaultBaseUri)
        {
            settings = settings ?? new HttpClientServiceSettings();

            m_httpClient  = settings.HttpClient ?? s_defaultHttpClient;
            m_aspects     = settings.Aspects;
            m_synchronous = settings.Synchronous;

            m_baseUri = settings.BaseUri ?? defaultBaseUri;
            if (m_baseUri == null || !m_baseUri.IsAbsoluteUri)
            {
                throw new ArgumentException("BaseUri must be specified and absolute.", nameof(settings));
            }

            ContentSerializer = settings.ContentSerializer ?? JsonHttpContentSerializer.Instance;
        }