public virtual async Task Dispatch(Event @event) { List<QueryModelBuilder> handlers; if(_handlers.TryGetValue(@event.GetType(), out handlers)) { await Task.WhenAll(handlers.Select(b => b.Handle(@event))); } else { throw new NotImplementedException($"No handler for eventtype {@event.GetType().FullName}"); } }
public override async Task Dispatch(Event @event) { List<QueryModelBuilder> handlers; if(_handlers.TryGetValue(@event.GetType(), out handlers)) { await Task.WhenAll( handlers.Select(b => { var builderType = b.GetType(); var queryModelBuilderService = ServiceProxy.Create<IQueryModelBuilderService>( $"{builderType.FullName}, {builderType.Assembly.GetName().Name}", new Uri("fabric:/CQRSMicroservices.ServiceFabric.Application/QueryModelBuilderService" )); return queryModelBuilderService.Handle(@event.ToJson()); }) ); } else { throw new NotImplementedException($"No handler for eventtype {@event.GetType().FullName}"); } }