コード例 #1
0
        private bool LoadRuntimeConfig()
        {
            if (!File.Exists(_recorderRuntimeConfigFilePath))
            {
                _currentRuntimeConfigFileLastUpdate = default;
                _currentRuntimeConfig = null;
                _logger.LogWarning($"Runtime Config file '{_recorderRuntimeConfigFilePath}' not found.");
                return(false);
            }

            var newUpdateDate = File.GetLastWriteTime(_recorderRuntimeConfigFilePath);

            if (_currentRuntimeConfig == null ||
                newUpdateDate > _currentRuntimeConfigFileLastUpdate)
            {
                _logger.LogInformation($"Loading Runtime Config file '{_recorderRuntimeConfigFilePath}'");
                _currentRuntimeConfig = RuntimeConfig.Load(_recorderRuntimeConfigFilePath);
                _currentRuntimeConfigFileLastUpdate = newUpdateDate;
                _logger.LogVerbose($"Runtime Config file loaded. " +
                                   $"Processes: {string.Join(", ", _currentRuntimeConfig.Processes.Select(p => p.ID))}" +
                                   $" - Last update: {newUpdateDate:O}");
            }
            return(true);
        }