Esempio n. 1
0
        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
            });
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
 public void Initialise()
 {
     nextClipboardViewer = (IntPtr)SetClipboardViewer((int)Handle);
     messageBus.Send(new ClipboardMonitorReadyMessage(this));
 }
Esempio n. 4
0
 public void Initialise(IWin32Window window)
 {
     Show(window);
     nextClipboardViewer = (IntPtr)SetClipboardViewer((int)Handle);
     messageBus.Send(new ClipboardMonitorReadyMessage(this));
 }
Esempio n. 5
0
 public void Configure(TexoConfiguration configuration)
 {
     Configuration = configuration;
     messageBus?.Send <ISettingUpdatedMessage>(new SettingUpdatedMessage(configuration));
 }
Esempio n. 6
0
 public ICommandResult Execute(CommandContext context)
 {
     messageBus?.Send <IClearViewOutputMessage>(new ClearViewOutputMessage());
     return(new TextResult("Output view cleared."));
 }