Exemplo n.º 1
0
        private void ContinueStartup()
        {
            var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder()
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);

            Configuration = builder.Build();

            var services = new ServiceCollection();

            services.AddOptions();
            services.Configure <ConfigWrapper>(Configuration);
            services.AddSingleton <IGraphService, GraphService>();
            services.AddSingleton <IHueService, HueService>();
            services.AddSingleton <LIFXService, LIFXService>();
            services.AddSingleton <IYeelightService, YeelightService>();
            services.AddSingleton <ICustomApiService, CustomApiService>();
            services.AddSingleton <LIFXOAuthHelper, LIFXOAuthHelper>();
            services.AddSingleton <MainWindow>();

            DiagnosticsClient.Initialize();

            ServiceProvider = services.BuildServiceProvider();

            var mainWindow = ServiceProvider.GetRequiredService <MainWindow>();

            mainWindow.Show();
        }
Exemplo n.º 2
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            SetAddRemoveProgramsIcon();

            var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder()
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);

            Configuration = builder.Build();

            var services = new ServiceCollection();

            services.AddOptions();
            services.Configure <ConfigWrapper>(Configuration);
            services.AddSingleton <IGraphService, GraphService>();
            services.AddSingleton <IHueService, HueService>();
            services.AddSingleton <MainWindow>();

            DiagnosticsClient.Initialize();

            ServiceProvider = services.BuildServiceProvider();

            var mainWindow = ServiceProvider.GetRequiredService <MainWindow>();

            mainWindow.Show();
        }
Exemplo n.º 3
0
#pragma warning disable CS8618 // Non-nullable field is uninitialized.
        public App()
#pragma warning restore CS8618 // Non-nullable field is uninitialized.
        {
            // Don't use the SocketHttphandler because it has some authentification issues accessing feeds like GitHub NuGet
            // see https://github.com/NuGetPackageExplorer/NuGetPackageExplorer/pull/841 for more details
            AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);

            DiagnosticsClient.Initialize();
        }
Exemplo n.º 4
0
 public App()
 {
     clock = Stopwatch.StartNew();
     this.LoadCompleted += App_LoadCompleted;
     DiagnosticsClient.Initialize();
     mainWindow = new MainWindow();
     mainWindow.Show();
     mainWindow.Activate();
 }
        public App()
        {
            const string invalidKey = "__BugsnagApiKey__";
            // Initialize Bugsnag if we have a valid key
            var apiKey      = ConfigurationManager.AppSettings["bugsnag:apiKey"];
            var sourceRoots = ConfigurationManager.AppSettings["bugsnag:sourceRoots"];

            if (!string.Equals(apiKey, invalidKey, StringComparison.OrdinalIgnoreCase))
            {
                DiagnosticsClient.Initialize(apiKey, sourceRoots);
            }
        }
Exemplo n.º 6
0
#pragma warning disable CS8618 // Non-nullable field is uninitialized.
        public App()
#pragma warning restore CS8618 // Non-nullable field is uninitialized.
        {
            // Initialize Bugsnag if we have a valid key
            var apiKey = ConfigurationManager.AppSettings["InstrumentationKey"];

            if (apiKey != "__AppInsightsKey__")
            {
                DiagnosticsClient.Initialize(apiKey);
            }

            DispatcherUnhandledException += App_DispatcherUnhandledException;
        }
Exemplo n.º 7
0
        private static void Main()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // If an error happens before we had a chance to init the environment information
            // the call to GetInformation() from BugReporter.ShowNBug() will fail.
            // There's no perf hit calling Initialise() multiple times.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);

            ThemeModule.Load();
            Application.ApplicationExit += (s, e) => ThemeModule.Unload();

            HighDpiMouseCursors.Enable();

            try
            {
                DiagnosticsClient.Initialize(ThisAssembly.Git.IsDirty);

                if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += (s, e) => BugReporter.Report((Exception)e.ExceptionObject, e.IsTerminating);
                    Application.ThreadException += (s, e) => BugReporter.Report(e.Exception, isTerminating: false);
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException != null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            // This is done here so these values can be used in the GitGui project but this project is the authority of the values.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);
            AppTitleGenerator.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.Branch);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
Exemplo n.º 8
0
        public BuildVisionPackage()
        {
            _logger.Information("Starting {ProductName} with Version {PackageVersion}", Resources.ProductName, ApplicationInfo.GetPackageVersion(this));

            PresentationTraceSources.Refresh();
            PresentationTraceSources.DataBindingSource.Listeners.Add(new SerilogTraceListener.SerilogTraceListener(_logger));
            PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Error | SourceLevels.Critical | SourceLevels.Warning;

            if (Application.Current != null)
            {
                Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
            }

            DiagnosticsClient.Initialize(GetEdition(), VisualStudioVersion.ToString(), "c437ad44-0c76-4006-968d-42d4369bc0ed");
        }
Exemplo n.º 9
0
        private static void Main()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // TODO: VSR - removed this because it was failing after switching to x64
            // ThemeModule.Load();
            // Application.ApplicationExit += (s, e) => ThemeModule.Unload();

            HighDpiMouseCursors.Enable();

            try
            {
                DiagnosticsClient.Initialize(VsrInfo.IsDirty);

                if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += (s, e) => ReportBug((Exception)e.ExceptionObject);
                    Application.ThreadException += (s, e) => ReportBug(e.Exception);
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException != null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            // This is done here so these values can be used in the GitGui project but this project is the authority of the values.
            UserEnvironmentInformation.Initialise(VsrInfo.Sha, VsrInfo.IsDirty);
            AppTitleGenerator.Initialise(VsrInfo.Sha, VsrInfo.Branch);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            InitializeLogging();

            this.InitializeComponent();
            this.Suspending += OnSuspending;

            DiagnosticsClient.Initialize(
#if __WASM__
                new NuGetPackageExplorer.Services.AppInsightsJsTelemetryService(
                    new List <ITelemetryServiceInitializer> {
                new NuGetPe.Utility.AppVersionTelemetryInitializer(),
                new NuGetPe.Utility.EnvironmentTelemetryInitializer()
            })
#endif
                );
        }
Exemplo n.º 11
0
        private void OnStartup(object sender, StartupEventArgs e)
        {
            var builder = new Microsoft.Extensions.Configuration.ConfigurationBuilder()
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);


            var builtConfig = builder.Build();

            var azureServiceTokenProvider = new AzureServiceTokenProvider();
            var keyVaultClient            = new KeyVaultClient(
                new KeyVaultClient.AuthenticationCallback(
                    azureServiceTokenProvider.KeyVaultTokenCallback));

            builder.AddAzureKeyVault(
                $"https://{builtConfig["KeyVaultName"]}.vault.azure.net/",
                keyVaultClient,
                new DefaultKeyVaultSecretManager());


            Configuration = builder.Build();

            var services = new ServiceCollection();

            services.AddOptions();
            services.Configure <ConfigWrapper>(Configuration);
            services.AddSingleton <IGraphService, GraphService>();
            services.AddSingleton <IHueService, HueService>();
            services.AddSingleton <LIFXService, LIFXService>();
            services.AddSingleton <LIFXOAuthHelper, LIFXOAuthHelper>();
            services.AddSingleton <MainWindow>();

            DiagnosticsClient.Initialize();

            ServiceProvider = services.BuildServiceProvider();

            var mainWindow = ServiceProvider.GetRequiredService <MainWindow>();

            mainWindow.Show();
        }
Exemplo n.º 12
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            HighDpiMouseCursors.Enable();

            try
            {
                DiagnosticsClient.Initialize(ThisAssembly.Git.IsDirty);

                if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += (s, e) => ReportBug((Exception)e.ExceptionObject);
                    Application.ThreadException += (s, e) => ReportBug(e.Exception);
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException != null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            // This is done here so these values can be used in the GitGui project but this project is the authority of the values.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
Exemplo n.º 13
0
        private static void Main()
        {
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // If an error happens before we had a chance to init the environment information
            // the call to GetInformation() from BugReporter.ShowNBug() will fail.
            // There's no perf hit calling Initialise() multiple times.
            UserEnvironmentInformation.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.IsDirty);

            AppSettings.SetDocumentationBaseUrl(ThisAssembly.Git.Branch);

#if SUPPORT_THEMES
            ThemeModule.Load();
            Application.ApplicationExit += (s, e) => ThemeModule.Unload();

            SystemEvents.UserPreferenceChanged += (s, e) =>
            {
                // Whenever a user changes monitor scaling (e.g. 100%->125%) unload and
                // reload the theme, and repaint all forms
                if (e.Category == UserPreferenceCategory.Desktop || e.Category == UserPreferenceCategory.VisualStyle)
                {
                    ThemeModule.ReloadWin32ThemeData();
                    foreach (Form form in Application.OpenForms)
                    {
                        form.BeginInvoke((MethodInvoker)(() => form.Invalidate()));
                    }
                }
            };
#endif

            HighDpiMouseCursors.Enable();

            try
            {
                DiagnosticsClient.Initialize(ThisAssembly.Git.IsDirty);

                // If you want to suppress the BugReportInvoker when debugging and exit quickly, uncomment the condition:
                ////if (!Debugger.IsAttached)
                {
                    AppDomain.CurrentDomain.UnhandledException += (s, e) => BugReportInvoker.Report((Exception)e.ExceptionObject, e.IsTerminating);
                    Application.ThreadException += (s, e) => BugReportInvoker.Report(e.Exception, isTerminating: false);
                }
            }
            catch (TypeInitializationException tie)
            {
                // is this exception caused by the configuration?
                if (tie.InnerException is not null &&
                    tie.InnerException.GetType()
                    .IsSubclassOf(typeof(ConfigurationException)))
                {
                    HandleConfigurationException((ConfigurationException)tie.InnerException);
                }
            }

            AppTitleGenerator.Initialise(ThisAssembly.Git.Sha, ThisAssembly.Git.Branch);

            // NOTE we perform the rest of the application's startup in another method to defer
            // the JIT processing more types than required to configure NBug.
            // In this way, there's more chance we can handle startup exceptions correctly.
            RunApplication();
        }
Exemplo n.º 14
0
#pragma warning disable CS8618 // Non-nullable field is uninitialized.
        public App()
#pragma warning restore CS8618 // Non-nullable field is uninitialized.
        {
            DiagnosticsClient.Initialize();
        }
Exemplo n.º 15
0
 public App()
 {
     DiagnosticsClient.Initialize();
 }