Esempio n. 1
0
        internal ReleaseNotesViewModel([NotNull] LauncherViewModel launcher, [NotNull] string version)
            : base(launcher.SafeArgument(nameof(launcher)).ServiceProvider)
        {
            if (version is null)
            {
                throw new ArgumentNullException(nameof(version));
            }

            this.launcher = launcher;

            Version = version;
            baseUrl = $"{RootUrl}/{Version}/ReleaseNotes/";
#if DEBUG
            if (Environment.CommandLine.ToLowerInvariant().Contains("/previewreleasenotes"))
            {
                var launcherPath = AppDomain.CurrentDomain.BaseDirectory;
                var mdPath       = Path.Combine(launcherPath, @"..\..\..\..\..\doc\");
                if (File.Exists($"{mdPath}{ReleaseNotesFileName}"))
                {
                    baseUrl = $"file:///{mdPath.Replace("\\", "/")}";
                }
            }
#endif

            ToggleCommand = new AnonymousCommand(ServiceProvider, Toggle);
        }
Esempio n. 2
0
 public string OnButtonPressed(ICommandBase onCommand)
 {
     this.onCommand = onCommand;
     onCommand.Execute();
     undoCommand = onCommand;
     return(Convert.ToString(undoCommand));
 }
 public void UnregisterCommand(ICommandBase command)
 {
     lock (_commandsLocker)
     {
         _commands.Add(command);
     }
 }
 public void ShowCommand(ICommandBase command)
 {
     if (command is OpenFileCommand ofcommand)
     {
         this.viewModel.ShowCommand(ofcommand);
     }
 }
Esempio n. 5
0
        private string GetArgumentDescriptionFor(ICommandBase command)
        {
            Trace.Assert(command != null);

              IEnumerable<CommandParam> args = command.GetParameters();
              return '(' + (args == null ? "" : String.Join(", ", args.Select(GetArgumentName).ToArray())) + ')';
        }
Esempio n. 6
0
        public ExecutionResult ProcessCommand(ICommandBase command)
        {
            ExecutionResult result = null;

            CommandProcessorKey key = new CommandProcessorKey(command.Name);

            //TODO: Не находит соответствия
            ICommandProcessor commandProcessor = this.registeredCommandProcessors[key];

            if (this.registeredCommandNotify.ContainsKey(key))
            {
                ICommandNotifyProcessor notifyHandler = this.registeredCommandNotify[key];

                notifyHandler.BeforeExecute(command);
                commandProcessor.Execute(command);
                //result = commandProcessor.Execute(command);
                notifyHandler.AfterExecute(command);
            }
            else
            {
                //result = commandProcessor.Execute(command);
                commandProcessor.Execute(command);
            }
            return(result);
        }
Esempio n. 7
0
        private string GetArgumentDescriptionFor(ICommandBase command)
        {
            Trace.Assert(command != null);

            IEnumerable <CommandParam> args = command.GetParameters();

            return('(' + (args == null ? "" : String.Join(", ", args.Select(GetArgumentName).ToArray())) + ')');
        }
Esempio n. 8
0
 /// <summary>
 /// Handles the CMS exception.
 /// </summary>
 /// <param name="ex">The exception.</param>
 /// <param name="command">The command.</param>
 /// <param name="request">The request.</param>
 private static void HandleCmsException(KnownException ex, ICommandBase command, object request = null)
 {
     Log.Error(FormatCommandExceptionMessage(command, request), ex);
     if (command.Context != null)
     {
         command.Context.Messages.AddError(Global.Message_InternalServerErrorPleaseRetry);
     }
 }
Esempio n. 9
0
        private void AddHelpImpl(IDictionary<string, string> dictionary, ICommandBase command)
        {
            Trace.Assert(command != null);
              Trace.Assert(dictionary != null);
              Trace.Assert(!dictionary.ContainsKey(command.GetName()));

              dictionary.Add(command.GetName(), GetHelpRowForCommand(command));
        }
        public async Task LogAsync(ICommandBase command, Exception exception)
        {
            var log = exception == null?CommandLog.Success(command) : CommandLog.Fail(command, exception);

            _context.CommandLogs.Add(log);

            await _context.SaveChangesAsync();
        }
Esempio n. 11
0
 /// <summary>
 /// Handles the security exception.
 /// </summary>
 /// <param name="ex">The ex.</param>
 /// <param name="command">The command.</param>
 /// <param name="request">The request.</param>
 private static void HandleSecurityException(SecurityException ex, ICommandBase command, object request = null)
 {
     Log.Error(FormatCommandExceptionMessage(command, request), ex);
     if (command.Context != null)
     {
         command.Context.Messages.AddError(RootGlobalization.Message_AccessForbidden);
     }
 }
Esempio n. 12
0
        private void AddHelpImpl(IDictionary <string, string> dictionary, ICommandBase command)
        {
            Trace.Assert(command != null);
            Trace.Assert(dictionary != null);
            Trace.Assert(!dictionary.ContainsKey(command.GetName()));

            dictionary.Add(command.GetName(), GetHelpRowForCommand(command));
        }
Esempio n. 13
0
        public Task SendAsync(ICommandBase command, CommandExecutionOptions executionOptions,
                              CancellationToken cancellationToken = default(CancellationToken))
        {
            var commandBus = commandRouter.FindRoute(command.GetType())
                             ?? throw new ArgumentException($"No route to a command bus found for command type {command.GetType()}");

            return(commandBus.SendAsync(command, executionOptions, cancellationToken));
        }
Esempio n. 14
0
 /// <summary>
 /// Handles the unknown exception.
 /// </summary>
 /// <param name="ex">The exception.</param>
 /// <param name="command">The command.</param>
 /// <param name="request">The request.</param>
 private static void HandleException(Exception ex, ICommandBase command, object request = null)
 {
     Log.Fatal(FormatCommandExceptionMessage(command, request), ex);
     if (command.Context != null)
     {
         command.Context.Messages.AddError(RootGlobalization.Message_InternalServerErrorPleaseRetry);
     }
 }
Esempio n. 15
0
 private bool SendConfigurationCommand(string hostAddress, ICommandBase cmd)
 {
     using (var socket = GetConnectedSocket(hostAddress))
     {
         SendCommand(socket, cmd);
         var ackResponse = new AcknowledgeResponse(socket);
         return(ackResponse.Acknowleged);
     }
 }
Esempio n. 16
0
        public SettingsViewModel()
        {
            _settingsHelper = ServiceLocator.Current.GetInstance <ISettingsHelper>();

            SaveSettingsCommand   = new CommandBase <SettingsViewModel>("Save", ExecuteSaveSettingsCommand);
            OpenFileDialogCommand = new CommandBase <SettingsViewModel>("Open", ExecuteOpenFileDialog);

            InitSettings();
        }
Esempio n. 17
0
 public override bool Process(ICommandBase command)
 {
     var res = command is ConnectCommand;
     if (!res)
     {
         throw new Exception("My Exception");
     }
     return res;
 }
Esempio n. 18
0
        public bool IsAuthenticationRequired(ICommandBase command)
        {
            if (commandTypePermissions.Value.TryGetValue(command.GetType(), out var info))
            {
                return(info.IsAuthenticationRequired);
            }

            throw new ArgumentException(
                      $"Unknown command type passed to IsAuthenticationRequired: {command.GetType().FullName}");
        }
Esempio n. 19
0
        public override bool Process(ICommandBase command)
        {
            var res = command is ConnectCommand;

            if (!res)
            {
                throw new Exception("My Exception");
            }
            return(res);
        }
Esempio n. 20
0
 internal VsixVersionViewModel(LauncherViewModel launcher, NugetStore store, string packageId)
     : base(launcher, store, null)
 {
     this.packageId       = packageId;
     status               = FormatStatus(Strings.ReportChecking);
     ExecuteActionCommand = new AnonymousTaskCommand(ServiceProvider, ExecuteAction)
     {
         IsEnabled = false
     };
 }
Esempio n. 21
0
        public IReadOnlyCollection <Permission> GetCommandPermissions(ICommandBase command)
        {
            if (commandTypePermissions.Value.TryGetValue(command.GetType(), out var permissions))
            {
                return(permissions);
            }

            throw new ArgumentException(
                      $"Unknown command type to GetCommandPermissions for: {command.GetType().FullName}");
        }
Esempio n. 22
0
        private Task InvokeHandleAsync(Type handlerType, ICommandBase command, CancellationToken cancellationToken)
        {
            Type   commandType  = command.GetType();
            object listener     = serviceLocator.Get(handlerType);
            var    handleMethod = listener.GetType()
                                  .GetRuntimeMethod(nameof(ICommandHandler <ICommand> .HandleAsync), new[] { commandType, typeof(CancellationToken) });

            return((Task)handleMethod.Invoke(listener, new object[] { command, cancellationToken }));
            // TODO test with contravariant handlers
        }
        public static IScope CreateCommandTraceScope(this ITracer tracer, ICommandBase command, string name)
        {
            var trace = tracer.BuildSpan(name).StartActive(true);

            //if (command.AggregateId != default)
            //{
            //    trace.Span.SetTag("aggregate.id", command.AggregateId.ToString());
            //}

            return(trace);
        }
Esempio n. 24
0
        public void ShowNotificationWindow(string title, string message, ICommandBase command, object commandParameter)
        {
            var notificationWindow = new NotificationWindow(title, message, command, commandParameter);

            lock (notificationWindows)
            {
                notificationWindows.Add(notificationWindow);
            }
            notificationWindow.Closed += (s, e) => { lock (notificationWindows) { notificationWindows.Remove(notificationWindow); } };
            notificationWindow.Show();
        }
Esempio n. 25
0
        public Task <object> ProcessAsync(ICommandBase command, CommandBusMiddlewareDelegate executionHandler,
                                          ICommandBus commandBus, CommandExecutionOptions executionOptions, CancellationToken cancellationToken)
        {
            var processMethod      = GetType().GetRuntimeMethods().Single(x => x.Name == "ProcessInternalAsync");
            var boundProcessMethod = processMethod.MakeGenericMethod(command.GetType());

            return((Task <object>)boundProcessMethod.Invoke(this, new object[]
            {
                command, executionHandler, commandBus, executionOptions, cancellationToken
            }));
        }
        public MainWindowViewModel(IGroupsRepository groups)
        {
            groupsRepository = groups;

            Results = new ObservableCollection <GroupModel>();
            Results.CollectionChanged += this.OnCollectionChanged <GroupModel>;

            OpenWindowCommand = new ICommandBase <WindowType>(OnOpenWindow);

            LoadConfig();
        }
Esempio n. 27
0
        private string GetHelpRowForCommand(ICommandBase command)
        {
            Trace.Assert(command != null);

            string        commandName = GetCommandName(command);
            StringBuilder sb          = new StringBuilder(commandName);

            sb.Append(":\n");
            sb.Append('\t').Append(command.GetHelpDescription()).Append('\n');
            sb.Append("\tArguments: ").Append(GetArgumentDescriptionFor(command)).Append('\n');
            return(sb.ToString());
        }
Esempio n. 28
0
        public async Task SendSagaCommandsAsync_SendsCommands()
        {
            Saga1 saga1 = new Saga1(Guid.NewGuid());

            saga1.Do();
            sut.Add(saga1);

            ICommandBase command = saga1.UncommitedCommands.First();

            await sut.SendSagaCommandsAsync();

            commandBus.Received(1).SendAsync(command);
        }
Esempio n. 29
0
        private string GetCommandName(ICommandBase command)
        {
            Trace.Assert(command != null);

            if (command is IConsoleCommand)
            {
                return('.' + command.GetName());
            }

            IInlineCommand icommand = (IInlineCommand)command;

            return(icommand.GetNameSpace() + '.' + icommand.GetName());
        }
Esempio n. 30
0
 private void ExecuteCommand(ICommandBase command)
 {
     try
     {
         command.Execute();
     }
     catch (Exception ex)
     {
         // TODO: LOG EXCEPTION
         Console.WriteLine(ex.Message);
         MessageBox.Show($"Unhandled error while executing command '{command.Name}'.\r\n\r\n{ex.Message}", "WinCommand Palette", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Esempio n. 31
0
        public Task SendAsync(ICommandBase command, CancellationToken cancellationToken)
        {
            Type genericCommandType = command.GetType().GetInterfaces().FirstOrDefault(
                x => x.IsConstructedGenericType && x.GetGenericTypeDefinition() == typeof(ICommand <>));
            Type handlerType;

            if (genericCommandType != null)
            {
                handlerType = typeof(ICommandHandler <,>).MakeGenericType(command.GetType(),
                                                                          genericCommandType.GetGenericArguments()[0]);
                return(InvokeHandleAsync(handlerType, command, cancellationToken));
            }

            handlerType = typeof(ICommandHandler <>).MakeGenericType(command.GetType());
            return(InvokeHandleAsync(handlerType, command, cancellationToken));
        }
        public void ShowCommand(ICommandBase command)
        {
            if (command is CSharpScriptCommand csscommand)
            {
                this.references.Clear();
                foreach (var item in csscommand.References)
                {
                    this.references.Add(item);
                }
                this.SortReferences();

                this.tbName.Text        = csscommand.Name;
                this.tbDescription.Text = csscommand.Description;
                this.tbCode.Text        = csscommand.Code;
            }
        }
Esempio n. 33
0
        /// <summary>
        /// <see cref="ICommand.CanExecuteChanged"/>を発行するか、集約処理に登録します。
        /// </summary>
        /// <param name="command"></param>
        public static void Post(ICommandBase command)
        {
            if (_dispatcher == null)
            {
                command.RaiseCanExecuteChanged();
            }
            else
            {
                if (_commands.Count == 0)
                {
                    _dispatcher.BeginInvoke(new Action(Processing), DispatcherPriority.DataBind);
                }

                _commands.Add(command);
            }
        }
 public override bool Process(ICommandBase command)
 {
     if (_commandsTracking.ContainsKey(command))
     {
         var index = Array.IndexOf(_commands, command);
         if (index == 0) // First Command, no special requirments
         {
             return true;
         }
         var prevCommand = _commands[index-1];
         if (_commandsTracking.ContainsKey(prevCommand))
         {
             return  _commandsTracking[prevCommand];
         }
         return false;
     }
     return true;
 }
Esempio n. 35
0
        private string GetHelpRowForCommand(ICommandBase command)
        {
            Trace.Assert(command != null);

              string commandName = GetCommandName(command);
              StringBuilder sb = new StringBuilder(commandName);
              sb.Append(":\n");
              sb.Append('\t').Append(command.GetHelpDescription()).Append('\n');
              sb.Append("\tArguments: ").Append(GetArgumentDescriptionFor(command)).Append('\n');
              return sb.ToString();
        }
Esempio n. 36
0
 public bool Process(ICommandBase command)
 {
     throw new NotImplementedException();
 }
Esempio n. 37
0
        private string GetCommandName(ICommandBase command)
        {
            Trace.Assert(command != null);

              if (command is IConsoleCommand) { return '.' + command.GetName(); }

              IInlineCommand icommand = (IInlineCommand) command;
              return icommand.GetNameSpace() + '.' + icommand.GetName();
        }
Esempio n. 38
0
 public bool Process(ICommandBase command)
 {
     return _processAction(command);
 }
Esempio n. 39
0
 public override bool Process(ICommandBase command)
 {
     // When there will be stop command
     return command is StopCommand;
 }
Esempio n. 40
0
 public abstract bool Process(ICommandBase command);