public static async Task Run( [QueueTrigger("events", Connection = "AzureStorage")] EventPublishedNotification myQueueItem, ILogger log, [Inject] IHandlerFactory factory) { await factory.Dispatch(myQueueItem); }
public async Task Dispatch(EventPublishedNotification notification) { var @event = notification.ToEvent(); var subscriberType = Type.GetType(notification.SubscriberType); var subscriber = this.ctx.GetInstance(subscriberType); await subscriber.ConsumeSubscribedEvent(@event); }
public static IAggregateEvent ToEvent(this EventPublishedNotification notification) { var eventType = Type.GetType(notification.EventType); return((IAggregateEvent)JsonConvert.DeserializeObject(notification.EventJson, eventType)); }