public async Task RunAsync() { var services = new ServiceCollection(); // Create a new instance of a service collection ConfigureServices(services); // Connect all our services RavenStore.Initialise(); // Setup our database connection var provider = services.BuildServiceProvider(); // Build the service provider provider.GetRequiredService <DiscordEventHandler>(); // Connect all our events await provider.GetRequiredService <StartupService>().StartAsync(); // Start the startup service await Task.Delay(-1); // Keep the program alive }
protected void Application_Start(object sender, EventArgs e) { //InitializeStore(); RavenStore.InitializeStore(); Store = RavenStore.Store; Bus = Configure.With() .DefineEndpointName(() => "SelfHealthCheck.WebMonitor") .DefaultBuilder() .UseTransport <Msmq>() .PurgeOnStartup(false) .UnicastBus() .RunHandlersUnderIncomingPrincipal(false) .MsmqSubscriptionStorage() .CreateBus() .Start(() => Configure.Instance.ForInstallationOn <NServiceBus.Installation.Environments.Windows>().Install()); }
public DefaultRegistry() { Scan( scan => { scan.TheCallingAssembly(); scan.WithDefaultConventions(); scan.With(new ControllerConvention()); }); //For<IExample>().Use<Example>(); For <IDocumentSession>().HttpContextScoped().Use(o => RavenStore.GetSession()); For <IPrincipal>().HttpContextScoped().Use(o => Thread.CurrentPrincipal); For <HttpContextBase>().Use(x => new HttpContextWrapper(HttpContext.Current)); For <IMailService>().Use <MandrillMailService>(); For <NLog.Logger>().Use(x => NLog.LogManager.GetLogger(x.ParentType == null ? x.RootType.FullName : x.ParentType.FullName)); For <IAuthenticationManager>().Use(() => HttpContext.Current.GetOwinContext().Authentication); For <IUserStore <User> >().Use <UserStore <User> >(); }