VsTeXProject.VisualStudio.Project.ProjectNode.AddFolderFromOtherProject C# (CSharp) Метод

AddFolderFromOtherProject() защищенный Метод

This is used to recursively add a folder from an other project. Note that while we copy the folder content completely, we only add to the project items which are part of the source project.
protected AddFolderFromOtherProject ( string folderToAdd, HierarchyNode targetNode ) : void
folderToAdd string Project reference (from data object) using the format: {Guid}|project|folderPath
targetNode HierarchyNode Node to add the new folder to
Результат void
        protected internal virtual void AddFolderFromOtherProject(string folderToAdd, HierarchyNode targetNode)
        {
            if (string.IsNullOrEmpty(folderToAdd))
                throw new ArgumentNullException("folderToAdd");
            if (targetNode == null)
                throw new ArgumentNullException("targetNode");

            // Split the reference in its 3 parts
            var index1 = Guid.Empty.ToString("B").Length;
            if (index1 + 1 >= folderToAdd.Length)
                throw new ArgumentOutOfRangeException("folderToAdd");

            // Get the Guid
            var guidString = folderToAdd.Substring(1, index1 - 2);
            var projectInstanceGuid = new Guid(guidString);

            // Get the project path
            var index2 = folderToAdd.IndexOf('|', index1 + 1);
            if (index2 < 0 || index2 + 1 >= folderToAdd.Length)
                throw new ArgumentOutOfRangeException("folderToAdd");

            // Finally get the source path
            var folder = folderToAdd.Substring(index2 + 1);

            // Get the target path
            var folderName = Path.GetFileName(Path.GetDirectoryName(folder));
            var targetPath = Path.Combine(GetBaseDirectoryForAddingFiles(targetNode), folderName);

            // Recursively copy the directory to the new location
            Utilities.RecursivelyCopyDirectory(folder, targetPath);

            // Retrieve the project from which the items are being copied
            IVsHierarchy sourceHierarchy;
            var solution = (IVsSolution) GetService(typeof (SVsSolution));
            ErrorHandler.ThrowOnFailure(solution.GetProjectOfGuid(ref projectInstanceGuid, out sourceHierarchy));

            // Then retrieve the item ID of the item to copy
            var itemID = VSConstants.VSITEMID_ROOT;
            ErrorHandler.ThrowOnFailure(sourceHierarchy.ParseCanonicalName(folder, out itemID));

            // Ensure we don't end up in an endless recursion
            if (Utilities.IsSameComObject(InteropSafeIVsHierarchy, sourceHierarchy))
            {
                var cursorNode = targetNode;
                while (cursorNode != null)
                {
                    if (string.Compare(folder, cursorNode.GetMkDocument(), StringComparison.OrdinalIgnoreCase) == 0)
                        throw new Exception();
                    cursorNode = cursorNode.Parent;
                }
            }

            // Now walk the source project hierarchy to see which node needs to be added.
            WalkSourceProjectAndAdd(sourceHierarchy, itemID, targetNode, false);
        }
ProjectNode