private void InvokeCommandHandler(IMessage message) { HandlerDispatcher handlerDispatcher; if (!_messageTypeToCommandHandler.TryGetValue(message.GetType(), out handlerDispatcher)) { var handlers = _assemblyScanner.FindCommandHandlersInAssemblies(message) ?? Enumerable.Empty<HandlerInfo>(); if (!handlers.Any()) return; if (handlers.Count() > 1) throw new Exception(string.Format("Multiple handlers present for command type {0} in app domain", message.GetType().FullName)); var methodInfo = handlers.Single(); var handlertype = typeof(ICommandHandler<>); handlerDispatcher = new HandlerDispatcher(message.GetType(), GenerateHandleAction(handlertype.MakeGenericType(message.GetType())), methodInfo.HandleMethod.DeclaringType, methodInfo.IsStatic ? _objectFactory.GetInstance(methodInfo.HandleMethod.DeclaringType) : null); _messageTypeToCommandHandler[message.GetType()] = handlerDispatcher; } var instance = handlerDispatcher.Instance ?? _objectFactory.GetInstance(handlerDispatcher.HandlerType); handlerDispatcher.HandleMethod(instance, message); }
private async Task FillViewDataDetailFormAsync(Institution item = null) { var cities = await HandlerDispatcher.ExecuteQueryAsync(new GetCitiesForInstitutionQuery()); ViewData["CityId"] = new SelectList(cities, "Id", "Name", item?.CityId); }
private async Task FillViewDataDetailFormAsync(City item = null) { var regions = await HandlerDispatcher.ExecuteQueryAsync(new GetRegionsForCityQuery()); ViewData["RegionId"] = new SelectList(regions, "Id", "Name", item?.RegionId); }
// GET: Admins public async Task <IActionResult> Admins() { var admins = await HandlerDispatcher.ExecuteQueryAsync(new GetAdminsQuery()); return(View(admins)); }
public Task PartialUpdateCategory(PartialUpdateCategoryCommand command, CancellationToken token) => HandlerDispatcher.Invoke <PartialUpdateCategoryHandler, PartialUpdateCategoryCommand>(command, token);
public Task UpdateCategory(UpdateCategoryCommand command, CancellationToken token) => HandlerDispatcher.Invoke <UpdateCategoryHandler, UpdateCategoryCommand>(command, token);
public Task DeleteCategory(DeleteCategoryCommand command, CancellationToken token) => HandlerDispatcher.Invoke <DeleteCategoryHandler, DeleteCategoryCommand>(command, token);
public Task AddCategoryBatch(AddCategoryBatchCommand command, CancellationToken token) => HandlerDispatcher.Invoke <AddCategoryBatchHandler, AddCategoryBatchCommand>(command, token);
public Task ArchiveCategory(ArchiveCategoryCommand command, CancellationToken token) => HandlerDispatcher.Invoke <ArchiveCategoryHandler, ArchiveCategoryCommand>(command, token);
public Task <CategoryDto> AddCategory(AddCategoryCommand command, CancellationToken token) => HandlerDispatcher.Invoke <AddCategoryHandler, AddCategoryCommand, CategoryDto>(command, token);
private async Task FillViewDataDetailFormAsync(ContestDetailsViewModel viewModel = null) { var areas = await HandlerDispatcher.ExecuteQueryAsync(new GetAreasForContestQuery()); ViewData["Areas"] = new MultiSelectList(areas, "Id", "Name", viewModel?.ContestAreas.Select(c => c.AreaId)); }