Esempio n. 1
0
        private MdNotesClient(
            TimeSpan timeout,
            Environment environment,
            string oAuthClientId,
            string oAuthRedirectUri,
            Models.OAuthToken oAuthToken,
            IDictionary <string, IAuthManager> authManagers,
            IHttpClient httpClient,
            IHttpClientConfiguration httpClientConfiguration)
        {
            this.Timeout                 = timeout;
            this.Environment             = environment;
            this.httpClient              = httpClient;
            this.authManagers            = (authManagers == null) ? new Dictionary <string, IAuthManager>() : new Dictionary <string, IAuthManager>(authManagers);
            this.HttpClientConfiguration = httpClientConfiguration;

            this.service = new Lazy <ServiceController>(
                () => new ServiceController(this, this.httpClient, this.authManagers));
            this.user = new Lazy <UserController>(
                () => new UserController(this, this.httpClient, this.authManagers));

            if (this.authManagers.ContainsKey("global"))
            {
                this.implicitOAuthManager = (ImplicitOAuthManager)this.authManagers["global"];
            }

            if (!this.authManagers.ContainsKey("global") ||
                !this.ImplicitOAuthCredentials.Equals(oAuthClientId, oAuthRedirectUri))
            {
                this.implicitOAuthManager   = new ImplicitOAuthManager(oAuthClientId, oAuthRedirectUri, oAuthToken, this);
                this.authManagers["global"] = this.implicitOAuthManager;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Sets OAuthToken.
 /// </summary>
 /// <param name="oAuthToken">OAuthToken.</param>
 /// <returns>Builder.</returns>
 public Builder OAuthToken(Models.OAuthToken oAuthToken)
 {
     this.oAuthToken = oAuthToken;
     return(this);
 }