public static string TemplateFormat(this ProjectFileInfo file) { ProjectFolderInfo folder = GetTopFolder(file); return(folder != null ? folder.TemplateFormat : String.Empty); }
public static ProjectFolderRole ProjectFolderRole(this ProjectFileInfo file) { ProjectFolderInfo folder = GetTopFolder(file); return(folder != null ? folder.ProjectFolderRole : Misc.ProjectFolderRole.ComponentLayout); }
public static void AddChildItems(ProjectFolderInfo projectFolder, string rootPath) { if (projectFolder == null) { return; } if (String.IsNullOrEmpty(projectFolder.FullPath)) { return; } if (!Directory.Exists(projectFolder.FullPath)) { Directory.CreateDirectory(projectFolder.FullPath); } ProjectFolderInfo topFolder = projectFolder.GetTopFolder(); ProjectFolderRole role = topFolder.ProjectFolderRole; string[] extensions = role == Misc.ProjectFolderRole.Binary ? Const.Extensions.Keys.ToArray() : new[] { "*.cshtml" }; string[] directories = Directory.GetDirectories(projectFolder.FullPath); string[] files = IO.Service.GetFiles(projectFolder.FullPath, extensions); if (directories.Length == 0 && files.Length == 0) { projectFolder.ChildItems = null; return; } List <ProjectItemInfo> newChildItems = new List <ProjectItemInfo>(); foreach (string dir in directories) { ProjectFolderInfo childFolder = null; if (projectFolder.ChildItems != null) { childFolder = projectFolder.ChildItems.FirstOrDefault(x => x.IsFolder && x.FullPath == dir) as ProjectFolderInfo; } if (childFolder == null) { childFolder = new ProjectFolderInfo { RootPath = rootPath, Path = dir.Replace(rootPath, "").Trim('\\'), Checked = false }; } childFolder.Parent = projectFolder; AddChildItems(childFolder, rootPath); newChildItems.Add(childFolder); } foreach (string file in files) { ProjectFileInfo childFile = null; if (projectFolder.ChildItems != null) { childFile = projectFolder.ChildItems.FirstOrDefault(x => x.IsFile && x.FullPath == file) as ProjectFileInfo; } if (childFile == null) { childFile = new ProjectFileInfo { RootPath = rootPath, Path = file.Replace(rootPath, "").Trim('\\'), Checked = false }; } childFile.Parent = projectFolder; newChildItems.Add(childFile); } projectFolder.ChildItems = newChildItems.Count > 0 ? newChildItems : null; }