Microsoft.VisualStudio.Project.ProjectNode.CreateFileNode C# (CSharp) Method

CreateFileNode() public method

Create a file node based on an msbuild item.
public CreateFileNode ( ProjectElement item ) : FileNode
item ProjectElement msbuild item
return FileNode
        public virtual FileNode CreateFileNode(ProjectElement item)
        {
            return new FileNode(this, item);
        }

Same methods

ProjectNode::CreateFileNode ( string file ) : FileNode

Usage Example

Esempio n. 1
0
        private static void AddNonMemberFileItems(ProjectNode project, IEnumerable<string> fileList)
        {
            ErrorHelper.ThrowIsNull(fileList, "fileList");

            foreach (string fileKey in fileList)
            {
                HierarchyNode parentNode = project;
                string[] pathItems = fileKey.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });

                if (StringComparer.OrdinalIgnoreCase.Equals(fileKey, project.ProjectFile))
                    continue;

                NemerleFolderNode topFolderNode = null;
                foreach (string fileOrDir in pathItems)
                {
                    string childNodeId = Path.Combine(parentNode.VirtualNodeName, fileOrDir);
                    FileInfo fileOrDirInfo = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId));
                    if ((fileOrDirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                        break;

                    HierarchyNode childNode = parentNode.FindChild(childNodeId);
                    if (childNode == null)
                    {
                        if (topFolderNode == null)
                        {
                            topFolderNode = parentNode as NemerleFolderNode;
                            if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded)
                                topFolderNode = null;
                        }

                        ProjectElement element = new ProjectElement(project, null, true);
                        element.Rename(childNodeId);
                        element.SetMetadata(ProjectFileConstants.Name, childNodeId);
                        childNode = project.CreateFileNode(element);
                        parentNode.AddChild(childNode);
                        break;
                    }

                    parentNode = childNode;
                }

                if (topFolderNode != null)
                    topFolderNode.CollapseFolder();
            }
        }
ProjectNode