Пример #1
0
        public void Execute(MacroEntry macro)
        {
            _invoker = MacroInvoker.GetInstance();

            void OnException(Exception exception)
            {
                UO.Commands.SystemMessage(string.Format(Strings.Macro_error___0_, exception.Message));

                if (exception is SyntaxErrorException syntaxError)
                {
                    UO.Commands.SystemMessage($"{Strings.Line_Number}: {syntaxError.RawSpan.Start.Line}");
                }
            }

            _invoker.ExceptionEvent += OnException;
            _invoker.Execute(macro);
            _invoker.ExceptionEvent -= OnException;
        }
Пример #2
0
        public static MacroInvoker GetInstance()
        {
            // ReSharper disable once InvertIf
            if (_instance == null)
            {
                lock ( _lock )
                {
                    if (_instance != null)
                    {
                        return(_instance);
                    }

                    _instance = new MacroInvoker();
                    return(_instance);
                }
            }

            return(_instance);
        }