예제 #1
0
        /// <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;
        }
예제 #2
0
 /// <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)
 {
 }
예제 #3
0
 /// <summary>
 /// Creates a new Tombola Umbraco Client connection.
 /// </summary>
 public UmbracoConnection(Target primaryTarget, UmbracoConnectionSettings connectionSettings, ICacheProvider cache)
     : this(primaryTarget, null, connectionSettings, cache)
 {
 }
예제 #4
0
 /// <summary>
 /// Creates a new Tombola Umbraco Client connection.
 /// </summary>
 public UmbracoConnection(Target primaryTarget, Target secondaryTarget, UmbracoConnectionSettings connectionSettings)
     : this(primaryTarget, secondaryTarget, connectionSettings, new HttpClient())
 {
 }
예제 #5
0
 /// <summary>
 /// Creates a new Tombola Umbraco Client connection.
 /// </summary>
 public UmbracoConnection(Uri primaryUmbracoApiAddress, UmbracoConnectionSettings connectionSettings)
     : this(new Target(primaryUmbracoApiAddress), connectionSettings)
 {
 }
예제 #6
0
 /// <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)
 {
 }