/// <summary> /// Process th e /// </summary> /// <param name="userLevel"></param> /// <returns></returns> bool IProcessConfiguration.ProcessConfiguration(System.Configuration.ConfigurationUserLevel userLevel) { try { Configuration config = ConfigurationManager.OpenExeConfiguration(userLevel); if (!config.HasFile) { return(true); } ConfigurationSection tempSection = null; ScaffoldSection section = null; try { tempSection = config.GetSection("scaffold"); section = tempSection as ScaffoldSection; } catch (ConfigurationException e) { Output.Error(ScaffoldResources.ProblemLoadingExeConfiguration(e.Message)); } if (section == null) { if (tempSection != null) { Output.Warning(ScaffoldResources.ScaffoldSectionPresentButWrongType); } // Otherwise the section just isn't there return(true); } GetBoolSetting(section, "Verbose", ref verbose); GetBoolSetting(section, "NoRemoting", ref noRemoting); } catch (ConfigurationErrorsException) { Output.Warning(ScaffoldResources.ApplicationConfigurationCouldNotBeLoaded); return(false); } return(true); }
private void GetBoolSetting(ScaffoldSection section, string setting, ref bool val) { try { for (int i = 0; i < section.Settings.Count; i++) { TypeElement element = section.Settings[i]; if (String.Compare(element.Key, setting, true) == 0) { if (!TryParseTrueFalse(element.Value, ref val)) { Output.Warning(ScaffoldResources.UnableToParseValueInConfig(element.Value, element.Key)); } return; } } } catch (ConfigurationException e) { Output.Warning(e.Message); } }