コード例 #1
0
        /// <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 async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            _dte = await GetServiceAsync <DTE>();

            var serviceProvider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_dte);
            var dialogService   = new VisualStudioDialogService(serviceProvider);
            var commandService  = await GetServiceAsync <IMenuCommandService>();

            var projectService  = new VcProjectService();
            var settingsService = new VisualStudioSettingsService(this);

            _solution = await GetServiceAsync <SVsSolution>() as IVsSolution;

            _solutionEventsHandler = new SolutionEventsHandler(this);
            _solution.AdviseSolutionEvents(_solutionEventsHandler, out var _solutionEventsCookie);

            _addConanDepends             = new AddConanDepends(commandService, dialogService, projectService, settingsService);
            _showPackageListCommand      = new ShowPackageListCommand(this, commandService, dialogService);
            _integrateIntoProjectCommand = new IntegrateIntoProjectCommand(commandService, dialogService, projectService);

            Logger.Initialize(serviceProvider, "Conan");

            SubscribeToEvents();
        }
コード例 #2
0
        public async Task IntegrateIntoProjectCommandCalculatesAProjectRelativePath()
        {
            var solutionDir = FileSystemUtils.CreateTempDirectory();

            FileSystemUtils.CreateTempFile(solutionDir, "conanfile.txt");

            var projectDir  = Directory.CreateDirectory(Path.Combine(solutionDir, "Project")).FullName;
            var projectPath = Path.Combine(projectDir, "Project.vcxproj");

            var project = new Mock <VCProject>();

            project.Setup(p => p.ProjectDirectory).Returns(projectDir);
            project.Setup(p => p.ProjectFile).Returns(projectPath);

            var projectService = new Mock <IVcProjectService>();

            projectService.Setup(p => p.GetActiveProject()).Returns(project.Object);

            var command = new IntegrateIntoProjectCommand(
                Mock.Of <IMenuCommandService>(),
                Mock.Of <IDialogService>(),
                projectService.Object);
            await command.MenuItemCallback();

            projectService.Verify(p => p.AddPropsImport(projectPath, @"..\conan\conanbuildinfo_multi.props"));
        }
コード例 #3
0
        /// <summary>Initialization of the package; this method is called right after the package is sited.</summary>
        protected override void Initialize()
        {
            base.Initialize();

            var dialogService   = new VisualStudioDialogService(this);
            var commandService  = GetService <IMenuCommandService>();
            var projectService  = new VcProjectService();
            var settingsService = new VisualStudioSettingsService(this);

            _addConanDepends             = new AddConanDepends(commandService, dialogService, projectService, settingsService);
            _showPackageListCommand      = new ShowPackageListCommand(this, commandService, dialogService);
            _integrateIntoProjectCommand = new IntegrateIntoProjectCommand(commandService, dialogService, projectService);
        }