/// <summary> /// Creates a new Tombola Umbraco Client connection. /// </summary> /// <exception cref="ArgumentNullException">thrown if any of the parameters are not given (are null)</exception> public UmbracoConnection(Target primaryTarget, Target secondaryTarget, UmbracoConnectionSettings connectionSettings, HttpClient httpClient, ICacheProvider cache = null) { if (primaryTarget == null) { throw new ArgumentNullException(nameof(primaryTarget)); } if (connectionSettings == null) { throw new ArgumentNullException(nameof(connectionSettings)); } if (httpClient == null) { throw new ArgumentNullException(nameof(httpClient)); } // Configure HttpClient httpClient.Timeout = connectionSettings.GlobalRequestTimeout; httpClient.DefaultRequestHeaders.Add("X-Tombola-ApiKey", "UB1eS3LZQMs9k6xXqAMMiZ1uvhhh2Gck"); this.httpClient = httpClient; // Configure cache this.cache = cache; if (cache != null) { cache.OnCacheMiss += Cache_OnCacheMiss; } // Create target provider this.targetProvider = new TargetProvider(primaryTarget, secondaryTarget, httpClient); ConnectionStatus = ConnectionStatus.UnInitialized; }
/// <summary> /// Creates a new Tombola Umbraco Client connection. /// </summary> public UmbracoConnection(Target primaryTarget, Target secondaryTarget, UmbracoConnectionSettings connectionSettings, ICacheProvider cache) : this(primaryTarget, secondaryTarget, connectionSettings, new HttpClient(), cache) { }
/// <summary> /// Creates a new Tombola Umbraco Client connection. /// </summary> public UmbracoConnection(Target primaryTarget, UmbracoConnectionSettings connectionSettings, ICacheProvider cache) : this(primaryTarget, null, connectionSettings, cache) { }
/// <summary> /// Creates a new Tombola Umbraco Client connection. /// </summary> public UmbracoConnection(Target primaryTarget, Target secondaryTarget, UmbracoConnectionSettings connectionSettings) : this(primaryTarget, secondaryTarget, connectionSettings, new HttpClient()) { }
/// <summary> /// Creates a new Tombola Umbraco Client connection. /// </summary> public UmbracoConnection(Uri primaryUmbracoApiAddress, UmbracoConnectionSettings connectionSettings) : this(new Target(primaryUmbracoApiAddress), connectionSettings) { }
/// <summary> /// Creates a new Tombola Umbraco Client connection. /// </summary> /// <exception cref="ArgumentNullException">thrown if any of the parameters are not given (are null)</exception> public UmbracoConnection(Uri primaryUmbracoApiAddress, UmbracoConnectionSettings connectionSettings, HttpClient httpClient, ICacheProvider cache = null) : this(new Target(primaryUmbracoApiAddress), null, connectionSettings, httpClient, cache) { }