/// <summary> /// This method is used to move dependant items from the main level (1st level below project node) to /// and make them children of the modules they belong to. /// </summary> /// <param name="child"></param> /// <returns></returns> internal bool AddDependant(HierarchyNode child) { // If the file is not a XSharpFileNode then drop it and create a new XSharpFileNode XSharpFileNode dependant; String fileName = child.Url; try { child.Remove(false); } catch (Exception e) { XSharpProjectPackage.Instance.DisplayOutPutMessage("AddDependant failed"); XSharpProjectPackage.Instance.DisplayException(e); } dependant = (XSharpFileNode)ProjectMgr.CreateDependentFileNode(fileName); // Like the C# project system we do not put a path in front of the parent name, even when we are in a subfolder // but we do put a path before the parent name when the parent is in a different folder // In that case the path is the path from the base project folder string parent = this.ItemNode.GetMetadata(ProjectFileConstants.Include); parent = Path.GetFileName(parent); if (!this.IsNonMemberItem) { string parentPath = Path.GetDirectoryName(Path.GetFullPath(this.Url)); string childPath = Path.GetDirectoryName(Path.GetFullPath(dependant.Url)); if (String.Equals(parentPath, childPath, StringComparison.OrdinalIgnoreCase)) { dependant.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parent); } else { string projectPath = this.ProjectMgr.ProjectFolder; Uri projectFolder = new Uri(projectPath); Uri relative = projectFolder.MakeRelativeUri(new Uri(parentPath)); parentPath = relative.ToString() + Path.DirectorySeparatorChar; dependant.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parentPath + parent); } } // Make the item a dependent item dependant.HasParentNodeNameRelation = true; // Insert in the list of children dependant.NextSibling = this.FirstChild; this.FirstChild = dependant; ProjectMgr.OnItemsAppended(this); this.OnItemAdded(this, dependant); // Set parent and inherit the NonMember Status dependant.Parent = this; dependant.IsDependent = true; dependant.IsNonMemberItem = this.IsNonMemberItem; return(true); }