コード例 #1
0
        public ApiPortVSPackage() : base()
        {
            s_serviceProvider = new ServiceProvider(this);
            _assemblyResolver = s_serviceProvider.GetService(typeof(AssemblyRedirectResolver)) as AssemblyRedirectResolver;

            if (_assemblyResolver == default(AssemblyRedirectResolver))
            {
                throw new InvalidOperationException("Could not find AssemblyRedirectResolver. It should have been resolved in the service provider.");
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
        }
コード例 #2
0
        public ApiPortVSPackage() : base()
        {
            s_serviceProvider = new ServiceProvider(this);
            _assemblyResolver = s_serviceProvider.GetService(typeof(AssemblyRedirectResolver)) as AssemblyRedirectResolver;

            if (_assemblyResolver == default(AssemblyRedirectResolver))
            {
                throw new InvalidOperationException(LocalizedStrings.CouldNotFindAssemblyRedirectResolver);
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
        }
コード例 #3
0
        // Called after constructor when package is sited
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            _serviceProvider = await ServiceProvider.CreateAsync(this);

            _assemblyResolver = _serviceProvider.GetService(typeof(AssemblyRedirectResolver)) as AssemblyRedirectResolver;

            if (_assemblyResolver == default(AssemblyRedirectResolver))
            {
                throw new InvalidOperationException(LocalizedStrings.CouldNotFindAssemblyRedirectResolver);
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            if (await GetServiceAsync(typeof(IMenuCommandService)) is OleMenuCommandService mcs)
            {
                var menuInitializer = await LocalServiceProviderAsync.GetServiceAsync(typeof(AnalyzeMenu)) as AnalyzeMenu;

                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                // Add menu items for Analyze toolbar menu
                var anazlyMenuCommandID = new CommandID(Guids.AnalyzeMenuItemCmdSet, (int)PkgCmdID.CmdIdAnalyzeMenuItem);
                var menuItem            = new MenuCommand(menuInitializer.AnalyzeMenuItemCallback, anazlyMenuCommandID);
                mcs.AddCommand(menuItem);

                var analyzeMenuOptionsCommandID = new CommandID(Guids.AnalyzeMenuItemCmdSet, (int)PkgCmdID.CmdIdAnalyzeOptionsMenuItem);
                var analyzeMenuOptionsItem      = new MenuCommand(ShowOptionsPage, analyzeMenuOptionsCommandID);
                mcs.AddCommand(analyzeMenuOptionsItem);

                var analyzeMenuToolbarCommandID = new CommandID(Guids.AnalyzeMenuItemCmdSet, (int)PkgCmdID.CmdIdAnalyzeToolbarMenuItem);
                var analyzeMenuToolbarItem      = new MenuCommand(async(_, e) => await ShowToolbarAsync().ConfigureAwait(false), analyzeMenuToolbarCommandID);
                mcs.AddCommand(analyzeMenuToolbarItem);

                // Add menu items for Project context menus
                var projectContextMenuCmdId = new CommandID(Guids.ProjectContextMenuItemCmdSet, (int)PkgCmdID.CmdIdProjectContextMenuItem);
                var contextMenuItem         = new OleMenuCommand(async(_, e) => await menuInitializer.AnalyzeSelectedProjectsAsync(false), projectContextMenuCmdId);
                contextMenuItem.BeforeQueryStatus += menuInitializer.ProjectContextMenuItemBeforeQueryStatus;
                mcs.AddCommand(contextMenuItem);

                var projectContextMenuDependentsCmdId = new CommandID(Guids.ProjectContextMenuItemCmdSet, (int)PkgCmdID.CmdIdProjectContextDependentsMenuItem);
                var contextMenuDependentsItem         = new OleMenuCommand(async(_, e) => await menuInitializer.AnalyzeSelectedProjectsAsync(true), projectContextMenuDependentsCmdId);
                contextMenuDependentsItem.BeforeQueryStatus += menuInitializer.ProjectContextMenuDependenciesItemBeforeQueryStatus;
                mcs.AddCommand(contextMenuDependentsItem);

                var projectContextMenuOptionsCmdId = new CommandID(Guids.ProjectContextMenuItemCmdSet, (int)PkgCmdID.CmdIdProjectContextOptionsMenuItem);
                var contextMenuOptionsItem         = new OleMenuCommand(ShowOptionsPage, projectContextMenuOptionsCmdId);
                contextMenuOptionsItem.BeforeQueryStatus += menuInitializer.ProjectContextMenuItemBeforeQueryStatus;
                mcs.AddCommand(contextMenuOptionsItem);

                // Add menu items for Solution context menus
                var solutionContextMenuCmdId = new CommandID(Guids.SolutionContextMenuItemCmdSet, (int)PkgCmdID.CmdIdSolutionContextMenuItem);
                var solutionContextMenuItem  = new OleMenuCommand(menuInitializer.SolutionContextMenuItemCallback, solutionContextMenuCmdId);
                solutionContextMenuItem.BeforeQueryStatus += menuInitializer.SolutionContextMenuItemBeforeQueryStatus;
                mcs.AddCommand(solutionContextMenuItem);

                var solutionContextMenuOptionsCmdId = new CommandID(Guids.SolutionContextMenuItemCmdSet, (int)PkgCmdID.CmdIdSolutionContextOptionsMenuItem);
                var solutionContextMenuOptionsItem  = new OleMenuCommand(ShowOptionsPage, solutionContextMenuOptionsCmdId);
                solutionContextMenuOptionsItem.BeforeQueryStatus += menuInitializer.SolutionContextMenuItemBeforeQueryStatus;
                mcs.AddCommand(solutionContextMenuOptionsItem);
            }
        }