public HttpStatusCodeCheckResultProvider(IAgentControlDefinitionProvider agentControlDefinitionProvider, IHttpStatusCodeFetcher httpStatusCodeFetcher)
        {
            if (agentControlDefinitionProvider == null)
            {
                throw new ArgumentNullException("agentControlDefinitionProvider");
            }

            if (httpStatusCodeFetcher == null)
            {
                throw new ArgumentNullException("httpStatusCodeFetcher");
            }

            this.agentControlDefinitionProvider = agentControlDefinitionProvider;
            this.httpStatusCodeFetcher = httpStatusCodeFetcher;

            // get initial check interval
            var agentControlDefinition = this.agentControlDefinitionProvider.GetControlDefinition();
            int checkIntervalInSeconds = DefaultCheckIntervalInSeconds;
            if (agentControlDefinition != null && agentControlDefinition.HttpStatusCodeCheck != null && agentControlDefinition.HttpStatusCodeCheck.CheckIntervalInSeconds > 0)
            {
                checkIntervalInSeconds = agentControlDefinition.HttpStatusCodeCheck.CheckIntervalInSeconds;
            }

            var timerStartTime = new TimeSpan(0, 0, 0);
            var timerInterval = new TimeSpan(0, 0, 0, checkIntervalInSeconds);
            this.timer = new Timer(state => this.UpdateHttpStatusCodeResult(), null, timerStartTime, timerInterval);
        }
Example #2
0
        public HttpStatusCodeCheckResultProvider(IAgentControlDefinitionProvider agentControlDefinitionProvider, IHttpStatusCodeFetcher httpStatusCodeFetcher)
        {
            if (agentControlDefinitionProvider == null)
            {
                throw new ArgumentNullException("agentControlDefinitionProvider");
            }

            if (httpStatusCodeFetcher == null)
            {
                throw new ArgumentNullException("httpStatusCodeFetcher");
            }

            this.agentControlDefinitionProvider = agentControlDefinitionProvider;
            this.httpStatusCodeFetcher          = httpStatusCodeFetcher;

            // get initial check interval
            var agentControlDefinition = this.agentControlDefinitionProvider.GetControlDefinition();
            int checkIntervalInSeconds = DefaultCheckIntervalInSeconds;

            if (agentControlDefinition != null && agentControlDefinition.HttpStatusCodeCheck != null && agentControlDefinition.HttpStatusCodeCheck.CheckIntervalInSeconds > 0)
            {
                checkIntervalInSeconds = agentControlDefinition.HttpStatusCodeCheck.CheckIntervalInSeconds;
            }

            var timerStartTime = new TimeSpan(0, 0, 0);
            var timerInterval  = new TimeSpan(0, 0, 0, checkIntervalInSeconds);

            this.timer = new Timer(state => this.UpdateHttpStatusCodeResult(), null, timerStartTime, timerInterval);
        }