예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Command1"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="commandService">Command service to add command to, not null.</param>
        private Command1(AsyncPackage package)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            try
            {
                _configuration = new ConfigurationBuilder()
                                 .SetBasePath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
                                 .AddXmlFile(@"_settings.config", optional: false)
                                 .Build();

                // create service collection
                var services = new ServiceCollection();
                ConfigureServices(services);

                _serviceProvider = services.BuildServiceProvider();
                ServiceLocator.SetLocatorProvider(_serviceProvider);

                _serviceProvider.GetRequiredService <DbUpdater>().UpdateDb();
                _serviceProvider.GetRequiredService <HistoryPlugin>().Register();
                _serviceProvider.GetRequiredService <SearchPlugin>().Register();
                _serviceProvider.GetRequiredService <DocumentPlugin>().Register();
                _serviceProvider.GetRequiredService <PreferencesUI>().Register();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetFullStackTraceWithMessage(), "Could not Load SSMSPlus");
                _serviceProvider.GetRequiredService <ILogger <Command1> >().LogCritical(ex, "Critical Error when starting pluging");

                throw;
            }
        }
 public IBus ResolveBus()
 {
     return(_provider.GetRequiredService <IBus>());
 }