private void OnMessageReceived(ChannelMessage channelMessage) { objectFactory.BeginScope(); var middlewares = LoadMiddlewares(); var middlewareInvoker = new MiddlewareInvoker(middlewares); middlewareInvoker.Invoke(new MiddlewareContext(channelMessage)); objectFactory.EndScope(); }
public void RunStartupTasks() { objectFactory.BeginScope(); var tasks = objectFactory.GetInstances <IStartupTask>(); foreach (var task in tasks.OrderBy(x => x.Name)) { try { log.Info($"Running StartupTask {task.Name}"); task.Run(); } catch (Exception ex) { log.Warn($"Failed to run StartupTask: {task.Name}", ex); } } objectFactory.EndScope(); }