private void UpdateVariable(string variable, string value) { if (string.IsNullOrWhiteSpace(value)) { value = string.Empty; } if (!variables.TryGetValue(variable, out string previousValue) && string.IsNullOrEmpty(value)) { return; } if (previousValue == value) { return; } strategies.TryGetValue(variable, out IVariableStrategy strategy); if (string.IsNullOrEmpty(value)) { if (!strategy?.CanBeRemoved(previousValue) ?? false) { return; } variables.Remove(variable); } else { if (!strategy?.IsValueValid(value, previousValue) ?? false) { return; } variables[variable] = value; } strategy?.OnValueChange(value); messageBus?.Send(new VariableUpdatedMessage(variable, value, previousValue) { Sender = this }); }
async void IMessageBusRecipient <ISettingUpdatedMessage> .ProcessMessage(ISettingUpdatedMessage message) { try { configuration = message.Configuration; tree = await Task.Run(() => BuildInputTree(message.Configuration)); if (configuration != message.Configuration) { return; } messageBus.Send <IInputTreeUpdatedMessage>(new InputTreeUpdatedMessage(configuration, tree)); } catch (System.Exception exception) { logger.Error("An unknown error happend during input tree build.", exception); } }
public void Initialise() { nextClipboardViewer = (IntPtr)SetClipboardViewer((int)Handle); messageBus.Send(new ClipboardMonitorReadyMessage(this)); }
public void Initialise(IWin32Window window) { Show(window); nextClipboardViewer = (IntPtr)SetClipboardViewer((int)Handle); messageBus.Send(new ClipboardMonitorReadyMessage(this)); }
public void Configure(TexoConfiguration configuration) { Configuration = configuration; messageBus?.Send <ISettingUpdatedMessage>(new SettingUpdatedMessage(configuration)); }
public ICommandResult Execute(CommandContext context) { messageBus?.Send <IClearViewOutputMessage>(new ClearViewOutputMessage()); return(new TextResult("Output view cleared.")); }