コード例 #1
0
 internal void CheckHostReachability()
 {
     if (openAPIDefinitionTicks != null && DateTime.UtcNow.Ticks >= openAPIDefinitionTicks + ServiceConfigurationForm.CHECK_HOST_INTERVAL_TICKS)
     {
         openAPIDefinition.BackColor = UrlChecker.CanReachOpenAPIDefinition(openAPIDefinition.Text, advancedConfigurationForm.GetProxyFor(openAPIDefinition.Text)) ? Color.LightGreen : Color.Red;
         openAPIDefinitionTicks      = null;
     }
 }
コード例 #2
0
        private YamlStream LoadUrl(string fileUrl)
        {
            HttpWebResponse response = UrlChecker.ConnectTo(fileUrl, UrlChecker.GetProxyFor(fileUrl), close: false);

            if (response == null || response.StatusCode != HttpStatusCode.OK)
            {
                string details = response == null ? "" : response.StatusDescription;
                Log.ErrorFormat("Configuration cannot be loaded from {0}: {1}.", fileUrl, details);
                if (response != null)
                {
                    response.Close();
                }
                return(null);
            }

            Log.InfoFormat("Configuration loaded from {0}: {1}.", fileUrl, response.StatusDescription);
            var parser = new YamlStream();
            var reader = new StreamReader(response.GetResponseStream());

            parser.Load(reader);
            reader.Close();
            response.Close();
            return(parser);
        }