/// <summary>
        /// Handles the configuration change event
        /// </summary>
        internal async Task HandleDidChangeConfigurationNotification(
            DidChangeConfigurationParams <TConfig> configChangeParams,
            EventContext eventContext)
        {
            Logger.Write(LogLevel.Verbose, "HandleDidChangeConfigurationNotification");

            // Propagate the changes to the event handlers
            var configUpdateTasks = ConfigChangeCallbacks.Select(
                t => t(configChangeParams.Settings, CurrentSettings, eventContext));
            await Task.WhenAll(configUpdateTasks);
        }
Exemple #2
0
        /// <summary>
        /// Handles the configuration change event
        /// </summary>
        internal async Task HandleDidChangeConfigurationNotification(
            DidChangeConfigurationParams <TConfig> configChangeParams,
            EventContext eventContext)
        {
            try
            {
                Logger.Write(LogLevel.Verbose, "HandleDidChangeConfigurationNotification");

                // Propagate the changes to the event handlers
                var configUpdateTasks = ConfigChangeCallbacks.Select(
                    t => t(configChangeParams.Settings, CurrentSettings, eventContext));
                await Task.WhenAll(configUpdateTasks);
            }
            catch (Exception ex)
            {
                Logger.Write(LogLevel.Error, "Unknown error " + ex.ToString());
                // Swallow exceptions here to prevent us from crashing
                // TODO: this probably means the ScriptFile model is in a bad state or out of sync with the actual file; we should recover here
                return;
            }
        }
 /// <summary>
 /// Adds a new task to be called when the configuration has been changed. Use this to
 /// handle changing configuration and changing the current configuration.
 /// </summary>
 /// <param name="task">Task to handle the request</param>
 public void RegisterConfigChangeCallback(ConfigChangeCallback task)
 {
     ConfigChangeCallbacks.Add(task);
 }