예제 #1
0
        /// <summary>
        /// Creates a folder inside the project.
        /// </summary>
        /// <param name="name">The name of the folder to create.</param>
        public virtual IFolderNode CreateFolder(string name)
        {
            Guard.NotNullOrEmpty(nameof(name), name);

            var automation = HierarchyNode.GetExtenderObject() as Project;

            if (automation == null)
            {
                throw new NotSupportedException(Strings.ProjectNode.AddFolderNotSupported(Name, name));
            }

            automation.ProjectItems.AddFolder(name);

            var folder = HierarchyNode.Children.FirstOrDefault(child =>
                                                               child.GetProperty <string>(VsHierarchyPropID.Name) == name);

            if (folder == null)
            {
                throw new InvalidOperationException(Strings.ProjectNode.AddFolderFailed(name, Name));
            }

            return(CreateNode(folder) as IFolderNode);
        }