private async System.Threading.Tasks.Task InitializeCommandsAsync(IProgress <ServiceProgressData> progress)
        {
            // if the package is zombied, we don't want to add commands
            if (Zombied)
            {
                return;
            }

            var progressData = new ServiceProgressData(VSIXResource.PackageLoad_WaitMessage, VSIXResource.PackageLoad_InitCommands,
                                                       currentStep: 2, TotalLoadSteps);

            progress?.Report(progressData);

            OleMenuCommandService oleCommandService = await this.GetServiceAsync <IMenuCommandService, OleMenuCommandService>();

            if (oleCommandService == null)
            {
                InvalidOperationException loadCommandServiceException = new InvalidOperationException("Failed to load OLE command service");
                AcuminatorLogger.LogException(loadCommandServiceException, logOnlyFromAcuminatorAssemblies: false, LogMode.Error);
                return;
            }

            FormatBqlCommand.Initialize(this, oleCommandService);
            GoToDeclarationOrHandlerCommand.Initialize(this, oleCommandService);
            BqlFixer.FixBqlCommand.Initialize(this, oleCommandService);

            OpenCodeMapWindowCommand.Initialize(this, oleCommandService);
        }
示例#2
0
        private async System.Threading.Tasks.Task InitializeCommandsAsync()
        {
            // if the package is zombied, we don't want to add commands
            if (Zombied)
            {
                return;
            }

            OleMenuCommandService oleCommandService = await this.GetServiceAsync <IMenuCommandService, OleMenuCommandService>();

            if (oleCommandService == null)
            {
                InvalidOperationException loadCommandServiceException = new InvalidOperationException("Failed to load OLE command service");
                AcuminatorLogger.LogException(loadCommandServiceException, logOnlyFromAcuminatorAssemblies: false, LogMode.Error);
                return;
            }

            FormatBqlCommand.Initialize(this, oleCommandService);
            GoToDeclarationOrHandlerCommand.Initialize(this, oleCommandService);
            BqlFixer.FixBqlCommand.Initialize(this, oleCommandService);

            OpenCodeMapWindowCommand.Initialize(this, oleCommandService);
        }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            FormatBqlCommand.Initialize(this);
            GoToDeclarationOrHandlerCommand.Initialize(this);
            base.Initialize();

            IComponentModel componentModel = Package.GetGlobalService(typeof(SComponentModel)) as IComponentModel;

            if (componentModel == null)
            {
                return;
            }

            InitializeLogger();

            try
            {
                componentModel.DefaultCompositionService.SatisfyImportsOnce(this);

                var container = new CompositionContainer(CompositionOptions.Default, componentModel.DefaultExportProvider);
                container.ComposeExportedValue <CodeAnalysisSettings>(new CodeAnalysisSettingsFromOptionsPage(GeneralOptionsPage));

                // Service Locator
                IServiceLocator serviceLocator = new MefServiceLocator(container);

                if (ServiceLocator.IsLocationProviderSet)
                {
                    serviceLocator = new DelegatingServiceLocator(ServiceLocator.Current, serviceLocator);
                }

                ServiceLocator.SetLocatorProvider(() => serviceLocator);
            }
            catch
            {
                // Exception will be logged in FCEL
            }
        }