Ejemplo n.º 1
0
        private void ReadAllConnectionStrings()
        {
            if (SetupConnectionStrings == null)
            {
                return;
            }

            foreach (var setupConnectionString in SetupConnectionStrings)
            {
                try
                {
                    var value = CLIConfig.ReadConnectionString(setupConnectionString.Name);
                    if (value == null)
                    {
                        throw new ArgumentException("value cannot be null");
                    }
                    ConnectionStrings.SetMember(setupConnectionString.Name, value);
                }
                catch (Exception ex)
                {
                    throw new CLIInfoException($"The config file must contain a ConnectionString called {setupConnectionString.Name}", ex);
                }
            }
        }
Ejemplo n.º 2
0
        private void ReadAllAppSettings()
        {
            if (SetupAppSettings == null)
            {
                return;
            }

            foreach (var setupAppSetting in SetupAppSettings)
            {
                try
                {
                    var value = CLIConfig.ReadAppSetting(setupAppSetting.Name, setupAppSetting.TypeConvert);
                    AppSettings.SetMember(setupAppSetting.Name, value);
                }
                catch (ArgumentNullException ex)
                {
                    throw new CLIInfoException($"The config file must contain an AppSetting called {setupAppSetting.Name}", ex);
                }
                catch (Exception ex)
                {
                    throw new CLIInfoException($"The config has an AppSetting called {setupAppSetting.Name} but it is probably of the wrong type", ex);
                }
            }
        }