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); }
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); } }
private string GetArgumentDescriptionFor(ICommandBase command) { Trace.Assert(command != null); IEnumerable<CommandParam> args = command.GetParameters(); return '(' + (args == null ? "" : String.Join(", ", args.Select(GetArgumentName).ToArray())) + ')'; }
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); }
private string GetArgumentDescriptionFor(ICommandBase command) { Trace.Assert(command != null); IEnumerable <CommandParam> args = command.GetParameters(); return('(' + (args == null ? "" : String.Join(", ", args.Select(GetArgumentName).ToArray())) + ')'); }
/// <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); } }
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(); }
/// <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); } }
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 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)); }
/// <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); } }
private bool SendConfigurationCommand(string hostAddress, ICommandBase cmd) { using (var socket = GetConnectedSocket(hostAddress)) { SendCommand(socket, cmd); var ackResponse = new AcknowledgeResponse(socket); return(ackResponse.Acknowleged); } }
public SettingsViewModel() { _settingsHelper = ServiceLocator.Current.GetInstance <ISettingsHelper>(); SaveSettingsCommand = new CommandBase <SettingsViewModel>("Save", ExecuteSaveSettingsCommand); OpenFileDialogCommand = new CommandBase <SettingsViewModel>("Open", ExecuteOpenFileDialog); InitSettings(); }
public override bool Process(ICommandBase command) { var res = command is ConnectCommand; if (!res) { throw new Exception("My Exception"); } return res; }
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}"); }
public override bool Process(ICommandBase command) { var res = command is ConnectCommand; if (!res) { throw new Exception("My Exception"); } return(res); }
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 }; }
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}"); }
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); }
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(); }
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(); }
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()); }
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); }
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()); }
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); } }
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; } }
/// <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; }
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(); }
public bool Process(ICommandBase command) { throw new NotImplementedException(); }
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(); }
public bool Process(ICommandBase command) { return _processAction(command); }
public override bool Process(ICommandBase command) { // When there will be stop command return command is StopCommand; }
public abstract bool Process(ICommandBase command);