示例#1
0
        public Connection(
            IProductHeaderValue productInformation,
            Uri baseAddress,
            ICredentialStore credentialStore,
            IHttpClient httpClient,
            IJsonSerializer serializer)
        {
            productInformation.ArgumentNotNull(nameof(productInformation));
            baseAddress.ArgumentNotNull(nameof(baseAddress));
            credentialStore.ArgumentNotNull(nameof(credentialStore));
            httpClient.ArgumentNotNull(nameof(httpClient));
            serializer.ArgumentNotNull(nameof(serializer));

            if (!baseAddress.IsAbsoluteUri)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The base address '{0}' must be an absolute URI", baseAddress), nameof(baseAddress));
            }

            UserAgent   = FormatUserAgent(productInformation);
            BaseAddress = baseAddress;
            Credentials = credentialStore.GetCredentials().Result;

            authenticator   = new Authenticator(credentialStore);
            this.httpClient = httpClient;
            jsonPipeline    = new JsonHttpPipeline(serializer);
        }
示例#2
0
        public Authenticator(ICredentialStore credentialStore)
        {
            credentialStore.ArgumentNotNull(nameof(credentialStore));

            CredentialStore = credentialStore;
        }