public ToolWindowViewModel(DTE dte, OptionsViewModel options, GenerateMenuItemsHelper generateMenuHelper, Func <InternalBlameWindow> internalBlameWindowAccessor) { this.generateMenuItemsHelper = generateMenuHelper; this.dte = new DteWrapper(dte); this.internalBlameWindowAccessor = internalBlameWindowAccessor; Options = options; ServiceContainer = new ServiceContainer(this); MergeCommand = new DelegateCommand <bool?>(Merge, CanMerge); MergeAllCommand = new DelegateCommand(MergeAll, CanMergeAll); UpdateCommand = new DelegateCommand(Update, CanUpdate); BlameCommand = new DelegateCommand(Blame, CanBlame); CheckInCommand = new DelegateCommand <CheckInTarget>(CheckIn, CanCheckIn); CompareCurrentVersionCommand = new DelegateCommand(CompareWithCurrentVersion, CanCompareWithCurrentVersion); ComparePortVersionCommand = new DelegateCommand(CompareWithPortVersion, CanCompareWithPortVersion); CompareCurrentWithPortCommand = new DelegateCommand(CompareCurrentWithPortVersion, CanCompareCurrentWithPortVersion); ManualMergeCommand = new DelegateCommand(ManualMerge, CanManualMerge); NavigateToSolutionCommand = new DelegateCommand(NavigateToSolution, CanNavigateToSolution); UndoCheckoutCommand = new DelegateCommand(UndoCheckout, CanUndoCheckout); ShowLogCommand = new DelegateCommand(ShowLog, CanShowLog); NavigateToFileCommand = new DelegateCommand <ProjectItemBase>(NavigateToItem, CanNavigateToItem); ShowAllCommand = new DelegateCommand(ShowAlllItems, CanShowAllItems); ShowCheckoutOnlyCommand = new DelegateCommand(ShowCheckoutOnly, CanSHowCheckoutOnly); ShowNewOnlyCommand = new DelegateCommand(ShowNewOnly, CanShowNewOnly); FilterCriteria = CreateFilterCriteria(Options.StartupFilterType); }
public void NavigateToSolution(string path, IDteWrapper dte) { Logger.AddInfo("NavigateToSolutionCommand. Start Navigate to: " + path); try { dte.OpenSolution(path); } catch (Exception e) { Logger.AddError("Can`t navigate to solution", e); MessageBox.Show("Can`t navigate to solution"); } Logger.AddInfo("NavigateToSolutionCommand. End navigate"); }
public void NavigateToSolution(DXVcsBranch currentBranch, IDteWrapper dte) { try { string filePath = Port.ProjectFilePath; string vcsFilePath = GetMergeVcsPathByOriginalPath(filePath, currentBranch); IDXVcsRepository repository = DXVcsRepositoryFactory.Create(Port.VcsServer); string targetPath = repository.GetFileWorkingPath(vcsFilePath); dte.OpenSolution(targetPath); } catch { MessageBox.Show("Can`t navigate to solution"); } }
public void AddReferences(IDteWrapper dte, NavigateItem item) { try { BusyIndicator.Show(); dte.ClearReferences(); SolutionParser parser = new SolutionParser(item.Path); foreach (var assembly in parser.GetReferencedAssemblies(true)) { dte.AddReference(assembly); } } finally { BusyIndicator.Close(); } }
public ToolWindowViewModel(DTE dte, OptionsViewModel options, GenerateMenuItemsHelper generateMenuHelper) { this.generateMenuItemsHelper = generateMenuHelper; this.dte = new DteWrapper(dte); Options = options; ServiceContainer = new ServiceContainer(this); MergeCommand = new DelegateCommand <bool?>(Merge, CanMerge); MergeAllCommand = new DelegateCommand(MergeAll, CanMergeAll); UpdateCommand = new DelegateCommand(Update, CanUpdate); BlameCommand = new DelegateCommand(Blame, CanBlame); CheckInCommand = new DelegateCommand <CheckInTarget>(CheckIn, CanCheckIn); CompareCurrentVersionCommand = new DelegateCommand(CompareWithCurrentVersion, CanCompareWithCurrentVersion); ComparePortVersionCommand = new DelegateCommand(CompareWithPortVersion, CanCompareWithPortVersion); ManualMergeCommand = new DelegateCommand(ManualMerge, CanManualMerge); NavigateToSolutionCommand = new DelegateCommand(NavigateToSolution, CanNavigateToSolution); UndoCheckoutCommand = new DelegateCommand(UndoCheckout, CanUndoCheckout); ShowLogCommand = new DelegateCommand(ShowLog, CanShowLog); NavigateToFileCommand = new DelegateCommand <ProjectItemBase>(NavigateToItem, CanNavigateToItem); }
static IEnumerable <MultiReference> ChangeVersion(IDteWrapper dte, ProjectType projectType, string newVersion) { var assemblyReferences = dte.GetReferences(x => x.Name.Contains("DevExpress")).Select(x => new MultiReference(x.Name, MultiReferenceType.Assembly).Do(mr => mr.ReplaceVersion(newVersion))); var projectReferences = dte.GetProjects(x => x.Name.Contains("DevExpress")).Select(x => new MultiReference(x.FullName, MultiReferenceType.Project).Do(mr => mr.ReplaceVersion(newVersion))); var assemplyReferenceNames = assemblyReferences.Select(x => x.AssemblySource); var projectReferenceNames = projectReferences.Select(x => x.AssemblySource); var model = SerializeHelper.DeSerializeNavigationConfig(); var projects = model.NavigateItems.Where(x => x.GeneratedProjects != null).SelectMany(x => x.GeneratedProjects).Distinct(); var targetProjects = projects.Select(x => new MultiReference(x, MultiReferenceType.Project)).Where(project => { var projectRoot = ProjectRootElement.Open(project.ProjectSource); if (project.ProjectSource.Contains("Localization") || SolutionParser.GetProjectType(projectRoot).Conflicts(projectType)) { return(false); } var assemblyNameProperty = SolutionParser.GetAssemblyNameFromProject(projectRoot).If(DXControlsVersionHelper.HasDXVersionInfo); if (assemblyNameProperty == null) { return(false); } if (projectReferenceNames.Contains(assemblyNameProperty)) { project.Type = MultiReferenceType.Project; return(true); } if (assemplyReferenceNames.Contains(assemblyNameProperty)) { project.Type = MultiReferenceType.Assembly; return(true); } return(false); }).ToList(); var dependentProjects = targetProjects.SelectMany(x => SolutionParser.GetDXReferencePaths(x.ProjectSource, true)).Where(x => !ReferenceInfo.IsEmpty(x)).Select(x => new MultiReference(x)).ToList(); return(Concat(targetProjects.ToList(), dependentProjects.ToList()).Distinct()); }
public SolitionEnumeratorHelper(IDteWrapper dte) { this.dte = dte; solution = dte.BuildTree(); }
public void AddProjectReferences(IDteWrapper dte, NavigateItem item) { AddReferencesImpl(dte, item, true); }
public void AddReferencesImpl(IDteWrapper dte, NavigateItem item, bool addAsProjectReference) { dte.LockCurrentProject(); try { BusyIndicator.Show(); string path = item.Path; SolutionParser parser = new SolutionParser(path); var projectType = parser.GetProjectType(); var newAssemblies = parser.GetReferencedAssemblies(!addAsProjectReference).Select(x => new MultiReference(x)); var newVersion = newAssemblies.Select(x => x.AssemblySource).FirstOrDefault(DXControlsVersionHelper.HasDXVersionInfo).With(DXControlsVersionHelper.GetDXVersionString); BusyIndicator.UpdateText("Search for references..."); var cache = SerializeHelper.DeserializeAddReferenceHelperCache(); var updatedReferenceCachedItem = cache.GetItem(path); IEnumerable <MultiReference> updatedReferences = null; if (updatedReferenceCachedItem != null) { updatedReferences = updatedReferenceCachedItem.References.Select(x => new MultiReference(x)).ToList(); } else { updatedReferences = ChangeVersion(dte, projectType, newVersion).ToList(); cache.AddItem(new AddReferenceHelperItem() { Solution = path, References = updatedReferences.Where(x => x.ReferenceSource != null).Select(x => x.ReferenceSource).ToList() }); SerializeHelper.SerializeAddReferenceHelperCache(cache); } BusyIndicator.UpdateText("Preparing project..."); dte.ClearReferences(); dte.ClearProjectReferences(); var actualReferences = Concat(newAssemblies, updatedReferences); if (addAsProjectReference) { actualReferences = Concat(actualReferences, parser.GetProjectPathes().Select(x => new MultiReference(x, MultiReferenceType.Project))); } foreach (var reference in actualReferences) { try { if (reference.Type == MultiReferenceType.Assembly) { var assembly = projectType == ProjectType.SL ? reference.FullAssemblySource : reference.AssemblySource; BusyIndicator.UpdateText("Add reference: " + assembly); dte.AddReference(assembly); } else { var project = reference.ProjectSource; BusyIndicator.UpdateText("Add project: " + project); dte.AddProjectReference(reference.ProjectSource); } } catch { } } } finally { BusyIndicator.Close(); dte.UnlockCurrentProject(); dte.ActivateConfiguration("DebugTest"); } }
public void AddReferences(IDteWrapper dte, NavigateItem item) { AddReferencesImpl(dte, item, false); }