public async Task Test_StartupException() { bool isDisposed = false; AssemblyUtils.SetEntryAssembly(GetType().Assembly); var applicationConfig = ApplicationConfigBuilder .Create() .WithApplicationName(ApplicationName) .WithScanDirectories( TestAssemblyDirectories ) // Add all file starting with Dapplo and ending on .dll .WithAssemblyPatterns("Dapplo*") .BuildApplicationConfig(); using (var bootstrapper = new ApplicationBootstrapper(applicationConfig)) { bootstrapper.Configure(); // Makes the startup break bootstrapper.Builder.Register(context => true); bootstrapper.RegisterForDisposal(SimpleDisposable.Create(() => isDisposed = true)); // Initialize, so we can export Assert.True(await bootstrapper.InitializeAsync().ConfigureAwait(false), "Not initialized"); // Start the composition, and IStartupActions await Assert.ThrowsAsync <NotSupportedException>(async() => await bootstrapper.StartupAsync().ConfigureAwait(false)); } // Dispose automatically calls IShutdownActions Assert.True(isDisposed); }
public static async Task <int> Main(string[] args) { using var bootstrapper = new ApplicationBootstrapper(); var application = new ConsoleApplication(bootstrapper); return(await application.Run(args)); }
static void Main(string[] args) { ApplicationBootstrapper.Boot(); Test t = new Test(); t.TestMethod(); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException; ApplicationBootstrapper.InitializeIfNeeds <AbpZeroTemplateXamarinIosModule>(); InstallFontPlugins(); global::Xamarin.Forms.Forms.Init(); ImageCircleRenderer.Init(); CachedImageRenderer.Init(); FormsPlugin.Iconize.iOS.IconControls.Init(); ConfigureFlurlHttp(); SetExitAction(); LoadApplication(new App()); return(base.FinishedLaunching(app, options)); }
public static WindsorContainer CreateContainer() { var container = new WindsorContainer(); ApplicationBootstrapper.ConfigureContainerForTests(container); return(container); }
public async Task TestStartupShutdown() { AssemblyUtils.SetEntryAssembly(GetType().Assembly); var applicationConfig = ApplicationConfigBuilder .Create() .WithApplicationName(ApplicationName) .WithScanDirectories(TestAssemblyDirectories) // Add all assemblies starting with Dapplo .WithAssemblyPatterns("Dapplo*") .BuildApplicationConfig(); using (var bootstrapper = new ApplicationBootstrapper(applicationConfig)) { bootstrapper.Configure(); #if DEBUG bootstrapper.EnableActivationLogging = true; #endif // Start the composition, and IStartupActions Assert.True(await bootstrapper.InitializeAsync().ConfigureAwait(false), "Couldn't run"); Assert.Contains(bootstrapper.LoadedAssemblies, addon => addon.GetName().Name.EndsWith("TestAddon")); } // Dispose automatically calls IShutdownActions }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException; ApplicationBootstrapper.InitializeIfNeeds <CIC_EPXamarinIosModule>(); global::Xamarin.Forms.Forms.Init(); ImageCircleRenderer.Init(); CachedImageRenderer.Init(); DebugServerIpAddresses.Current = "localhost"; //Set this address as your local computer IP. Eg: 192.168.1.120 ConfigureFlurlHttp(); #if DEBUG TrustLocalDeveloperCert(); #endif SetExitAction(); LoadApplication(new App()); return(base.FinishedLaunching(app, options)); }
protected override void ConfigureApplicationContainer(IContainer existingContainer) { // Perform registation that should have an application lifetime ApplicationBootstrapper.Init(); var documentStore = new DocumentStore { Url = "http://localhost:8080", DefaultDatabase = "Todo" }; documentStore.Conventions.FindTypeTagName = type => { if (typeof(Domain.IEvent).IsAssignableFrom(type)) { return(type.Name); } //Crude way of making the State id's a little bit prettier if (type.Name.EndsWith("State")) { return(Inflector.Pluralize(type.Name.Remove(type.Name.LastIndexOf("State", StringComparison.InvariantCulture), 5))); } return(DocumentConvention.DefaultTypeTagName(type)); }; documentStore.Initialize(); existingContainer.Configure(cfg => { cfg.For <IDocumentStore>().Use(documentStore).Singleton(); cfg.Scan(scanner => { scanner.AssemblyContainingType <CreateTodoItem>(); scanner.AssemblyContainingType <IMediator>(); scanner.AddAllTypesOf(typeof(IRequestHandler <,>)); scanner.AddAllTypesOf(typeof(IEventHandler <>)); scanner.AddAllTypesOf(typeof(IPreRequestHandler <>)); scanner.AddAllTypesOf(typeof(IPostRequestHandler <,>)); scanner.WithDefaultConventions(); }); cfg.For <IDocumentSession>() .Use(ctx => ctx.GetInstance <IDocumentStore>() .OpenSession()); cfg.For <IManageUnitOfWork>() .Use <RavenDbUnitOfWork>(); cfg.For(typeof(IRequestHandler <,>)) .DecorateAllWith(typeof(MediatorPipeline <,>)); cfg.For <ITodoItemRepository>().Use <TodoItemRepository>(); }); }
public void TestConstructorAndCleanup() { var applicationConfig = ApplicationConfigBuilder .Create() .WithApplicationName(ApplicationName) .BuildApplicationConfig(); var bootstrapper = new ApplicationBootstrapper(applicationConfig); bootstrapper.Dispose(); }
public void TestConstructorWithMutexAndCleanup() { var applicationConfig = ApplicationConfigBuilder .Create() .WithApplicationName("Test") .WithMutex(Guid.NewGuid().ToString()) .BuildApplicationConfig(); using (var bootstrapper = new ApplicationBootstrapper(applicationConfig)) { Assert.False(bootstrapper.IsAlreadyRunning); } }
public void SetupContainer() { _container = new WindsorContainer(); _container.ConfigureWiringForTestsCallBeforeAllOtherWiring(); ApplicationBootstrapper.ConfigureContainer(_container); _container.Register( Component.For <IServiceBus>().ImplementedBy <SynchronousBus>() .Named("TestReplacementServiceBus") .LifestylePerWebRequest() .IsDefault() ); _container.ConfigureWiringForTestsCallAfterAllOtherWiring(); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException; Forms.SetFlags("CollectionView_Experimental"); ApplicationBootstrapper.InitializeIfNeeds <FloodCitiSenseXamarinIosModule>(); SharpnadoInitializer.Initialize(); Forms.Init(); ImageCircleRenderer.Init(); FormsGoogleMaps.Init("AIzaSyA_4G_We4nEDQ-R3mfipus-bIM1lHAMbUc"); FormsGoogleMapsBindings.Init(); CachedImageRenderer.Init(); CarouselViewRenderer.Init(); ConfigureFlurlHttp(); PlotViewRenderer.Init(); SetExitAction(); Material.Init(); Rg.Plugins.Popup.Popup.Init(); if (options == null) { LoadApplication(new App(false)); } else { LoadApplication(new App(options.ContainsKey(new NSString(ApsNotificationKey)))); } FacebookClientManager.Initialize(app, options); ProcessNotification(options, true); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { _locationManager.RequestAlwaysAuthorization(); } if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0)) { _locationManager.AllowsBackgroundLocationUpdates = true; } RegisterForRemoteNotifications(); return(base.FinishedLaunching(app, options)); }
public override void Init() { base.Init(); if (initialized) { return; } lock (initializationLock) { if (initialized) { return; } var bootstrapper = new ApplicationBootstrapper(); var container = bootstrapper.Configure(); DependencyResolver.SetResolver(new WindsorDependencyResolver(container)); initialized = true; } }
/// <summary> /// Create the Dapplication with the specified ApplicationConfig /// Take care that you called WithCaliburnMicro on your builder, or added the needed assemblies yourself /// </summary> /// <param name="applicationConfig">ApplicationConfig</param> public Dapplication(ApplicationConfig applicationConfig) { _bootstrapper = new ApplicationBootstrapper(applicationConfig); Current = this; // Hook unhandled exceptions in the Dispatcher DispatcherUnhandledException += HandleDispatcherException; // Hook unhandled exceptions in the AppDomain AppDomain.CurrentDomain.UnhandledException += HandleAppDomainException; // Hook unhandled exceptions in tasks TaskScheduler.UnobservedTaskException += HandleTaskException; // Make the bootstrapper stop when the CurrentDispatcher is going to shutdown, this uses a little hack to make sure there is no block Dispatcher.CurrentDispatcher.ShutdownStarted += (s, e) => { StopBootstrapperAsync().WaitWithNestedMessageLoop(); }; }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException; ApplicationBootstrapper.InitializeIfNeeds <CoreAngularDemoXamarinIosModule>(); global::Xamarin.Forms.Forms.Init(); ImageCircleRenderer.Init(); CachedImageRenderer.Init(); ConfigureFlurlHttp(); SetExitAction(); LoadApplication(new App()); return(base.FinishedLaunching(app, options)); }
public static async Task <int> Main(string[] args) { LogSettings.RegisterDefaultLogger <DebugLogger>(LogLevels.Verbose); var applicationConfig = ApplicationConfigBuilder.Create() .WithApplicationName("DemoConsoleApp") .WithScanDirectories( #if DEBUG @"..\..\..\..\Dapplo.Addons.TestAddonWithCostura\bin\Debug\netstandard2.0", #else @"..\..\..\..\Dapplo.Addons.TestAddonWithCostura\bin\Release\netstandard2.0", #endif FileLocations.StartupDirectory, @"MyOtherLibs" ) .WithAssemblyNames("Dapplo.HttpExtensions", "Dapplo.Addons.TestAddonWithCostura").BuildApplicationConfig(); using (var bootstrapper = new ApplicationBootstrapper(applicationConfig)) { #if DEBUG bootstrapper.EnableActivationLogging = true; #endif bootstrapper.Configure(); await bootstrapper.InitializeAsync().ConfigureAwait(false); bootstrapper.Container.Resolve <ServiceStartupShutdown>(); // Find all, currently, available assemblies if (Log.IsDebugEnabled()) { foreach (var resource in bootstrapper.Resolver.EmbeddedAssemblyNames()) { Log.Debug().WriteLine("Available embedded assembly {0}", resource); } } Assembly.Load("Dapplo.HttpExtensions"); } return(0); }
protected override void OnStartup(StartupEventArgs e) { var stateManager = new DefaultApplicationStateManger(); stateManager.GotToNewState(ApplicationState.BOOTSTRAPPING); try { base.OnStartup(e); ApplicationBootstrapper bootstrapper = new ApplicationBootstrapper(stateManager); bootstrapper.Run(); this._applicationContent = bootstrapper.ContentContainer; stateManager.GotToNewState(ApplicationState.RUNTIME); Current.MainWindow = (Window)bootstrapper.CurrentShell; Current.MainWindow.Show(); } #pragma warning disable 168 catch (Exception exception) #pragma warning restore 168 { stateManager.GotToNewState(ApplicationState.FATAL_ERROR); /*TODO: do some work here on notifying a user about the failure*/ throw; } }
private static BootstrapData BootstrapApplication() { // If we're not on EC2, then we'll not even try bootstrapping the application. if (!IsEc2) { return(null); } // Uses ambient AWS credentials, probably from an IAM role. // This should be exactly the same as just creating the clients without passing the credentials. // It is left explicit to guarantee the same algorithm is used to get credentials here as it is // in Startup.Autofac.cs. AWSCredentials credentials = AmbientCredentials.GetCredentials(); IAmazonEC2 ec2Client = AWSClientFactory.CreateAmazonEC2Client(credentials); IAmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client(credentials); var instanceService = new InstanceService(ec2Client); var storageService = new StorageService(s3Client, new S3PathParser()); var metadataService = new MetadataService(); var bootstrapper = new ApplicationBootstrapper(instanceService, storageService, metadataService); return(bootstrapper.BootstrapApplication()); }
public static void Boot() { ApplicationBootstrapper.Boot(); }
public void ConfigureServices(IServiceCollection services) { try { services.AddDbContext <ApplicationDbContext>( setup => setup.UseSqlServer(Configuration["db:default"], options => { options.MigrationsAssembly("HashTag.Presentation"); })); services.AddIdentity <ApplicationUser, ApplicationRole>( setup => { setup.Password.RequiredLength = 6; setup.Password.RequireLowercase = false; setup.Password.RequireUppercase = false; setup.Password.RequireDigit = false; setup.Password.RequireNonAlphanumeric = false; }) .AddEntityFrameworkStores <ApplicationDbContext>() .AddDefaultTokenProviders(); services.AddAuthorization( options => { options.AddPolicy("admin", policy => policy.RequireRole("admin")); }); var authenticationBuilder = services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme); authenticationBuilder.AddCookie(setup => { setup.Cookie.Name = "_HashTagAuth"; setup.ExpireTimeSpan = TimeSpan.FromDays(1); setup.SlidingExpiration = true; setup.AccessDeniedPath = "/error/403"; }); if (!string.IsNullOrEmpty(Configuration["authentication:facebook:appId"])) { authenticationBuilder.AddFacebook(setup => { setup.AppId = Configuration["authentication:facebook:appId"]; setup.AppSecret = Configuration["authentication:facebook:appSecret"]; }); } if (!string.IsNullOrEmpty(Configuration["authentication:google:clientId"])) { authenticationBuilder.AddGoogle(setup => { setup.ClientId = Configuration["authentication:google:clientId"]; setup.ClientSecret = Configuration["authentication:google:clientSecret"]; }); } services.AddSession(); services.AddMvc( options => { if (bool.Parse(Configuration["config:requireHttpsFilterEnabled"])) { options.Filters.Add(new RequireHttpsAttribute { Permanent = true }); } options.Filters.Add(typeof(ApplicationExceptionFilter)); if (bool.Parse(Configuration["config:historyLogsEnabled"])) { options.Filters.Add(typeof(RequestHistoryLogFilterAttribute)); } options.Filters.Add(typeof(UnitOfWorkFilter)); }) .AddJsonOptions( option => { option.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); option.SerializerSettings.Formatting = Formatting.Indented; option.SerializerSettings.Converters.Add(new StringEnumConverter()); }); services.AddSingleton <IConfiguration>(Configuration); services.TryAddScoped <IHttpContextAccessor, HttpContextAccessor>(); services.Configure <MessagesOptions>(Configuration.GetSection("messages")); ApplicationBootstrapper.ApplyAllBootstrappers(services); } catch (Exception exception) { new ApplicationLogger().LogFatal(exception); throw; } }
/// <summary> /// CaliburnMicroBootstrapper /// </summary> /// <param name="bootstrapper">Used to register, inject, export and locate</param> public CaliburnMicroBootstrapper(ApplicationBootstrapper bootstrapper) { _bootstrapper = bootstrapper; }
// Launches the startup task protected override async void OnResume() { base.OnResume(); ApplicationBootstrapper.InitializeIfNeeds <CruisePMSXamarinAndroidModule>(); await CheckInternetAndStartApplication(); }
// Launches the startup task protected override void OnResume() { base.OnResume(); ApplicationBootstrapper.InitializeIfNeeds <FloodCitiSenseXamarinAndroidModule>(); StartApplication(); }