예제 #1
0
 static void WriteParsingFailure(WriteToLogDelegate writeToLogDelegate, string configFile,
                                 string appSettingsKey, string value, Type type)
 {
     writeToLogDelegate?.Invoke($"The configuration file {configFile} has a setting, {appSettingsKey}" +
                                $" having the value {value}, which cannot be parsed to a(n) {type}. " +
                                "The setting is therefore ignored.");
 }
예제 #2
0
        void HandleUpdateConfigurationFileError(bool removedUser, bool removedApp, WriteToLogDelegate writeToLog)
        {
            if (removedUser && removedApp)
            {
                return;
            }

            string message = string.Empty;

            switch (ConfigFileUse)
            {
            case ConfigFileUse.ApplicationConfig:
                if (!removedApp)
                {
                    message = $"the application configuration file {applicationConfiguration.FilePath}.";
                }
                break;

            case ConfigFileUse.UserConfig:
                if (!removedUser)
                {
                    message = $"the user configuration file {userConfigFilePath}.";
                }
                break;

            case ConfigFileUse.BothConfig:
                if (!removedApp && !removedUser)
                {
                    message = $"the application configuration file {applicationConfiguration.FilePath}" +
                              " and the user configuration file {userConfigFilePath}.";
                }
                break;

            default:
                throw new InvalidDataException("Unexpected value for ConfigFileUse: " +
                                               $"{ConfigFileUse}.");
            }

            writeToLog?.Invoke("Failed to update " + message);
        }