コード例 #1
0
        static void Main(string[] args)
        {
            var bootstrapper = new Bootstrapper();
            bootstrapper.Startup();

            //var dispatcherService = SimpleIoc.Default.GetInstance<IDispatcherService>();

            System.Console.WriteLine("Sample.Console successfully bootstrapped");
            System.Console.ReadLine();
        }
コード例 #2
0
        public void ShouldStartupBootstrapperInBackgroundThread()
        {
            // Arrange
            var bootstrapper = new Bootstrapper();

            // Act
            Action startupAction = () =>
                {
                    // The unit test framework is run in a background thread
                    // Bootstrapper.Startup should survive this situation without exception
                    bootstrapper.Startup();
                };

            // Assert
            startupAction.ShouldNotThrow();
        }
コード例 #3
0
        /// <summary>
        ///     Invoked when the application is launched normally by the end user.  Other entry points
        ///     will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            var bootstrapper = new Bootstrapper();
            bootstrapper.Startup();
#if DEBUG
            if (Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                // Set the default language
                rootFrame.Language = ApplicationLanguages.Languages[0];

                rootFrame.NavigationFailed += this.OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
コード例 #4
0
        /// <summary>
        ///     Constructor for the Application object.
        /// </summary>
        public App()
        {
            var bootstrapper = new Bootstrapper();
            bootstrapper.Startup();

            // Global handler for uncaught exceptions.
            this.UnhandledException += this.Application_UnhandledException;

            // Standard XAML initialization
            this.InitializeComponent();

            // Phone-specific initialization
            this.InitializePhoneApplication();

            // Language display initialization
            this.InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
        }
コード例 #5
0
        public void ShouldStartupBootstrapper()
        {
            // Arrange
            IBootstrapper bootstrapper = new Bootstrapper();

            // Act
            bootstrapper.Startup();

            // Assert
            bootstrapper.ApplicationLifecycle.Should().Be(ApplicationLifecycle.Running);
        }
コード例 #6
0
        public void ShouldShutdownBootstrapper()
        {
            // Arrange
            IBootstrapper bootstrapper = new Bootstrapper();
            bootstrapper.Startup();

            // Act
            bootstrapper.Shutdown();

            // Assert
            bootstrapper.ApplicationLifecycle.Should().Be(ApplicationLifecycle.Uninitialized);
        }