/// <summary> /// Finds IProjectTree node in the top level children of a given parent IProjectTree node. /// Depending on the type of IDependencyNode search method is different: /// - if dependency node has custom ItemSpec, we only can find it by caption. /// - if dependency node has normal ItemSpec, we first try to find it by path and then /// by caption if path was not found (since unresolved and resolved items can have /// different items specs). /// </summary> private IProjectTree FindProjectTreeNode(IProjectTree parentNode, IDependencyNode nodeInfo, string projectFolder) { IProjectTree treeNode = null; if (nodeInfo.Flags.Contains(DependencyNode.CustomItemSpec)) { treeNode = parentNode.FindNodeByCaption(nodeInfo.Caption); } else { var itemSpec = nodeInfo.Id.ItemSpec; if (!ManagedPathHelper.IsRooted(itemSpec)) { itemSpec = ManagedPathHelper.TryMakeRooted(projectFolder, itemSpec); } if (!string.IsNullOrEmpty(itemSpec)) { treeNode = parentNode.FindNodeByPath(itemSpec); } if (treeNode == null) { treeNode = parentNode.FindNodeByCaption(nodeInfo.Caption); } } return(treeNode); }
private static string GetFullPath(string originalItemSpec, string containingProjectPath) { if (string.IsNullOrEmpty(originalItemSpec) || ManagedPathHelper.IsRooted(originalItemSpec)) { return(originalItemSpec ?? string.Empty); } return(ManagedPathHelper.TryMakeRooted(containingProjectPath, originalItemSpec)); }
private static string MakeRooted(string projectFolder, string path) { if (string.IsNullOrEmpty(path)) { return(null); } if (ManagedPathHelper.IsRooted(path)) { return(path); } else { return(ManagedPathHelper.TryMakeRooted(projectFolder, path)); } }
/// <summary> /// Tries to convert OriginalItemSpec to absolute path for given dependency. If OriginalItemSpec is /// absolute path, just returns OriginalItemSpec. If OriginalItemSpec is not absoulte, tries to make /// OriginalItemSpec rooted to current project folder. /// </summary> public static string GetActualPath(this IDependency dependency, string containingProjectPath) { var dependencyProjectPath = dependency.OriginalItemSpec; if (string.IsNullOrEmpty(dependency.OriginalItemSpec)) { return(null); } if (!ManagedPathHelper.IsRooted(dependency.OriginalItemSpec)) { dependencyProjectPath = ManagedPathHelper.TryMakeRooted(containingProjectPath, dependency.OriginalItemSpec); } return(dependencyProjectPath); }