Example #1
0
        internal File(Folder parentFolder)
        {
            if (parentFolder == null) throw new ArgumentNullException();

            Parent = parentFolder;
            DirectoryPath = parentFolder.Path;
        }
Example #2
0
 internal Folder(string name, Folder parentFolder)
 {
     Name = name;
     if (parentFolder != null)
     {
         Parent = parentFolder;
         DirectoryPath = System.IO.Path.Combine(parentFolder.DirectoryPath, name);
     }
 }
Example #3
0
        internal static Stack<Folder> GetFolderStack(Folder folder)
        {
            var folderStack = new Stack<Folder>();
            folderStack.Push(folder);

            Folder parent = folder.Parent;
            while (parent != null && !(parent is Project))
            {
                folderStack.Push(parent);
                parent = parent.Parent;
            }
            return folderStack;
        }
Example #4
0
        private static File FindFile(Folder folder, string path)
        {
            foreach (var file in folder.Files)
            {
                if (file.Path == path) return file;
            }

            foreach (var subFolder in folder.Folders)
            {
                var result = FindFile(subFolder, path);
                if (result != null) return result;
            }

            return null;
        }
Example #5
0
 public Folder NewFolder(string name, Folder parentFolder)
 {
     return new Folder(name, parentFolder);
 }
Example #6
0
 public File NewFile(string name, Folder parentFolder)
 {
     return new File(parentFolder){ Name = name };
 }
 internal FolderProxy(string name, Folder parentFolder)
     : base(name, parentFolder)
 {
 }
        private File AddFileToFolder(Folder folder, ProjectItem item)
        {
            var newFile = new FileProxy(folder);
            newFile.VsProjectItem = item;
            newFile.Name = item.Name;
            folder.Items.Add(newFile);

            foreach (ProjectItem codeBehindItem in item.ProjectItems)
            {
                var codeBehindFile = new FileProxy(folder);
                codeBehindFile.Name = codeBehindItem.Name;
                codeBehindFile.VsProjectItem = codeBehindItem;
                newFile.Items.Add(codeBehindFile);
            }

            return newFile;
        }
 internal FileProxy(Folder parentFolder)
     : base(parentFolder)
 {
 }
        private void AddFilesAndFolders(Folder parentFolder, ProjectItem parentVsItem)
        {
            for (int x = 1; x <= parentVsItem.ProjectItems.Count; x++)
            {
                var vsItem = parentVsItem.ProjectItems.Item(x);
                if (vsItem.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFolder)
                {
                    var newFolder = new FolderProxy(vsItem.Name, parentFolder);
                    newFolder.VsProjectItem = vsItem;
                    newFolder.DirectoryPath = new System.IO.DirectoryInfo(vsItem.get_FileNames(0)).FullName;

                    parentFolder.Items.Add(newFolder);

                    if (vsItem.ProjectItems.Count > 0)
                        AddFilesAndFolders(newFolder, vsItem);
                }
                else if (vsItem.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFile)
                {
                    var newFile = AddFileToFolder(parentFolder, vsItem);
                }
            }
        }
 public Folder NewFolder(string name, Folder parentFolder)
 {
     if (parentFolder is FolderProxy)
     {
         var parentFolderProxy = parentFolder as FolderProxy;
         var newFolder = new FolderProxy(name, parentFolderProxy);
         var newVsFolder = parentFolderProxy.VsProjectItem.ProjectItems.AddFolder(name, EnvDTE.Constants.vsProjectItemKindPhysicalFolder);
         newFolder.VsProjectItem = newVsFolder;
         return newFolder;
     }
     else
     {
         var parentProjectProxy = parentFolder as ProjectProxy;
         var newFolder = new FolderProxy(name, parentProjectProxy);
         var newVsFolder = parentProjectProxy.VsProject.ProjectItems.AddFolder(name, EnvDTE.Constants.vsProjectItemKindPhysicalFolder);
         newFolder.VsProjectItem = newVsFolder;
         return newFolder;
     }
 }
        public File NewFile(string name, Folder parentFolder)
        {
            var parentFolderProxy = parentFolder as FolderProxy;

            var newFile = new FileProxy(parentFolder){ Name = name };

            using (var f = newFile.NewFileStream()) ;
            var newProjectItem = parentFolderProxy.VsProjectItem.ProjectItems.AddFromFile(newFile.Path);

            newFile.VsProjectItem = newProjectItem;

            return newFile;
        }
Example #13
0
        public virtual void AddFolder(Folder folder)
        {
            if (folder == null) throw new ArgumentNullException();

            Items.Add(folder);
        }
Example #14
0
        public virtual Folder NewFolder(string name)
        {
            if (HasFolder(name))
                throw new ArgumentException("Folder already exists");
            ThrowExceptionIfPathIsNotSet();

            var newFolder = new Folder(name, this);
            Items.Add(newFolder);

            return newFolder;
        }