AddProject() public method

public AddProject ( Project project ) : void
project Solutionizer.Models.Project
return void
コード例 #1
0
        public void CanAddSaveSolutionWithNestedProjectReferences()
        {
            CopyTestDataToPath("CsTestProject1.csproj", Path.Combine(_testDataPath, "sub", "p1"));
            CopyTestDataToPath("CsTestProject2.csproj", Path.Combine(_testDataPath, "sub", "p2"));
            CopyTestDataToPath("CsTestProject3.csproj", Path.Combine(_testDataPath, "p3", "sub"));

            _scanningCommand = new ScanningCommand(_testDataPath, true);
            _scanningCommand.Start().Wait();

            Project project;
            _scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "p3", "sub", "CsTestProject3.csproj"), out project);

            var solution = new SolutionViewModel(_settings, _testDataPath, _scanningCommand.Projects);
            solution.AddProject(project);

            // we need to change the Guid of the reference folder
            var refFolder = solution.SolutionItems.OfType<SolutionFolder>().First();
            refFolder.Guid = new Guid("{95374152-F021-4ABB-B317-74A183A89F00}");
            refFolder.Items.OfType<SolutionFolder>().First().Guid = new Guid("{CE1BA3BF-4957-4CBC-9D45-3DC68106B311}");

            var targetPath = Path.Combine(_testDataPath, "test.sln");

            var cmd = new SaveSolutionCommand(_settings, targetPath, VisualStudioVersion.VS2010, solution);
            cmd.Execute();

            Assert.AreEqual(ReadFromResource("CsTestProject3.sln"), File.ReadAllText(targetPath));
        }
コード例 #2
0
        public void OnDoubleClick(ItemViewModel itemViewModel)
        {
            var projectViewModel = itemViewModel as ProjectViewModel;

            if (projectViewModel != null)
            {
                _solution.AddProject(projectViewModel.Project);
            }
        }
コード例 #3
0
        public void CanAddProject()
        {
            CopyTestDataToPath("CsTestProject1.csproj", _testDataPath);

            _scanningCommand = new ScanningCommand(_testDataPath, true);
            _scanningCommand.Start().Wait();

            Project project;
            _scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "CsTestProject1.csproj"), out project);

            var sut = new SolutionViewModel(new DummyStatusMessenger(), _settings, _testDataPath, _scanningCommand.Projects);
            sut.AddProject(project);

            Assert.AreEqual(1, sut.SolutionItems.Count);
            Assert.AreEqual("CsTestProject1", sut.SolutionItems[0].Name);
            Assert.AreEqual(typeof (SolutionProject), sut.SolutionItems[0].GetType());
        }
コード例 #4
0
        public void CanAddSaveSolution()
        {
            CopyTestDataToPath("CsTestProject1.csproj", _testDataPath);

            _scanningCommand = new ScanningCommand(_testDataPath, true);
            _scanningCommand.Start().Wait();

            Project project;
            _scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "CsTestProject1.csproj"), out project);

            var solution = new SolutionViewModel(_settings, _testDataPath, _scanningCommand.Projects);
            solution.AddProject(project);

            var targetPath = Path.Combine(_testDataPath, "test.sln");

            var cmd = new SaveSolutionCommand(_settings, targetPath, VisualStudioVersion.VS2010, solution);
            cmd.Execute();

            Assert.AreEqual(ReadFromResource("CsTestProject1.sln"), File.ReadAllText(targetPath));
        }
コード例 #5
0
        public void CanAddProjectWithProjectReference()
        {
            CopyTestDataToPath("CsTestProject1.csproj", Path.Combine(_testDataPath, "p1"));
            CopyTestDataToPath("CsTestProject2.csproj", Path.Combine(_testDataPath, "p2"));

            _scanningCommand = new ScanningCommand(_testDataPath, true);
            _scanningCommand.Start().Wait();

            Project project;
            _scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "p2", "CsTestProject2.csproj"), out project);

            var sut = new SolutionViewModel(new DummyStatusMessenger(), _settings, _testDataPath, _scanningCommand.Projects);
            sut.AddProject(project);

            Assert.AreEqual(2, sut.SolutionItems.Count);
            Assert.AreEqual("_References", sut.SolutionItems[0].Name);
            Assert.AreEqual("CsTestProject2", sut.SolutionItems[1].Name);

            Assert.AreEqual(1, ((SolutionFolder) sut.SolutionItems[0]).Items.Count);
            Assert.AreEqual("CsTestProject1", ((SolutionFolder) sut.SolutionItems[0]).Items[0].Name);
        }
コード例 #6
0
        public ShellViewModel(ISettings settings, IDialogManager dialogManager, IFlyoutManager flyoutManager, IUpdateManager updateManager, IViewModelFactory viewModelFactory, IMostRecentUsedFoldersRepository mostRecentUsedFoldersRepository)
        {
            _settings         = settings;
            _dialogManager    = dialogManager;
            _flyoutManager    = flyoutManager;
            _updateManager    = updateManager;
            _viewModelFactory = viewModelFactory;
            _mostRecentUsedFoldersRepository = mostRecentUsedFoldersRepository;

            _projectRepository = _viewModelFactory.CreateProjectRepositoryViewModel(new RelayCommand <ProjectViewModel>(projectViewModel => _solution.AddProject(projectViewModel.Project)));
            _updateManager.UpdatesAvailable          +=
                (sender, args) => AreUpdatesAvailable = _updateManager.Releases != null && _updateManager.Releases.Any(r => r.IsNew && (_settings.IncludePrereleaseUpdates || !r.IsPrerelease));

            ShowUpdatesCommand    = new RelayCommand <bool>(checkForUpdates => _flyoutManager.ShowFlyout(_viewModelFactory.CreateUpdateViewModel(checkForUpdates)));
            ShowSettingsCommand   = new RelayCommand(OnShowSettings);
            ShowAboutCommand      = new RelayCommand(() => _flyoutManager.ShowFlyout(_viewModelFactory.CreateAboutViewModel()));
            SelectRootPathCommand = new AsyncRelayCommand(SelectRootPath);
            SetRootPathCommand    = new AsyncRelayCommand <string>(LoadProjectsAsync, path => !String.Equals(path, RootPath));

            _updateTimer = new Timer(_ => _updateManager.CheckForUpdatesAsync(), null, -1, -1);
        }