public static Settings FromConfigSettings(ConfigurationSettings configSettings)
 {
     return(new Settings()
     {
         Scan = ScanSettings.FromConfigSettings(configSettings),
         HealthReport = HealthReportSettings.FromConfigSettings(configSettings),
         PatchVerification = PatchVerificationSettings.FromConfigSettings(configSettings),
         PatchInstallation = PatchInstallationSettings.FromConfigSettings(configSettings)
     });
 }
        public static HealthReportSettings FromConfigSettings(ConfigurationSettings settings)
        {
            var healthReportSettings = new HealthReportSettings();

            if (!settings.Sections.Contains(SectionName))
            {
                return(healthReportSettings);
            }

            var configSection = settings.Sections[SectionName];

            foreach (var prop in configSection.Parameters)
            {
                ParseConfigurationProperty(prop, healthReportSettings);
            }

            return(healthReportSettings);
        }
        private static void ParseConfigurationProperty(
            ConfigurationProperty prop,
            HealthReportSettings healthReportSettings)
        {
            switch (prop.Name)
            {
            case "RemoveWhenExpired":
            {
                var removeWhenExpired = false;
                if (bool.TryParse(prop.Value, out removeWhenExpired))
                {
                    healthReportSettings.RemoveWhenExpired = removeWhenExpired;
                }
                break;
            }

            case "TimeToLiveSeconds":
            {
                var timeToLiveSeconds = 0;
                if (int.TryParse(prop.Value, out timeToLiveSeconds))
                {
                    healthReportSettings.TimeToLiveSeconds = timeToLiveSeconds;
                }
                break;
            }

            case "ReportMissingAs":
            {
                var reportMissingAs = HealthState.Unknown;
                if (Enum.TryParse(prop.Value, out reportMissingAs))
                {
                    healthReportSettings.ReportMissingAs = reportMissingAs;
                }
                break;
            }
            }
        }