/// <summary> /// Request switch. /// </summary> /// <param name="singleSwitch">Command.</param> public void RequestSwitch(FunctionSwitch singleSwitch) { try { loggerPool.Log(singleSwitch.ServiceType.ServiceType, new LogContentEntity() { Message = singleSwitch.Command.ToString() }); commandInvoker.Invoke <ExecuteResult>(singleSwitch); callback.Notify(MessageEntity.NormalInfo(singleSwitch.ServiceType, singleSwitch.Command.ToString())); } catch (Exception ex) { var fex = new FaultException(new FaultReason(ex.Message), new FaultCode("002"), "RequestSwitch"); loggerPool.Log(singleSwitch.ServiceType.ServiceType, new LogContentEntity(fex.Message + fex.StackTrace) { Level = "Error" }); throw fex; } }
static void Main(string[] args) { var serviceProvider = new ServiceCollection() .AddLogging(config => config.AddConsole().SetMinimumLevel(LogLevel.Debug)) .AddTaCqrs() .AddCommandHandler <AddCustomerCommandHandler, AddCustomerCommand>() .AddScoped <IContextDataProvider, ContextDataProvider>() .BuildServiceProvider(); Stopwatch stopwatch = Stopwatch.StartNew(); ILoggerFactory loggerFactory = serviceProvider.GetService <ILoggerFactory>(); ILogger logger = loggerFactory.CreateLogger <Program>(); ICommandInvoker commandInvoker = serviceProvider.GetService <ICommandInvoker>(); for (int i = 0; i < 10; i++) { ExecutionResponse executionResponse = commandInvoker.Invoke(new AddCustomerCommand() { Name = "Customer 1" }).Result; logger.LogDebug($"{executionResponse.AdditionalData.GetCreatedAt()}"); } stopwatch.Stop(); logger.LogDebug($"{stopwatch.Elapsed}"); logger.LogDebug("Completed!, Press any key to exit"); Console.WriteLine($"{stopwatch.Elapsed}"); Console.ReadKey(); }
private async Task ProcessMessage(Message message) { var args = new TelegramMessageEventArgs { ChatId = message.Chat.Id, MessageId = message.MessageId, From = message.From, Message = message }; var results = await _invoker.Invoke(args); foreach (var result in results) { //сюда reply sender } }
private async Task ProcessMessage(Message message) { var args = new TelegramMessageEventArgs { ChatId = message.Chat.Id, MessageId = message.MessageId, From = message.From, Message = message }; var results = await _invoker.Invoke(args); foreach (var result in results) { await _replySender.Send(result, args.ChatId); await Task.Delay(300); } }
public void DoSomething() { var command = new ChangeNameCommand(1, "asdf"); invoker.Invoke(command); }
public void DeleteImage(string publicKey) { _commandInvoker.Invoke(new DeleteImage(_cloudinaryAdapter), publicKey); }
public void OpenChooser() { ChooserResult = invoker.Invoke("ASCOM.Utilities.Chooser", "Choose", new[] { "" }); }
public void CreateContact(Contact contact) { _commandInvoker.Invoke(new SaveContact(_contactRepository), contact); }
public object Invoke(CommandInvocation commandInvocation) { _actionBeforeInvocation(commandInvocation); return(_inner.Invoke(commandInvocation)); }
private static void DoSomething() { _commandInvoker.Invoke <IStoreAddressCommand>(x => x.Execute()); }