static string GetCategoryForProject (Dictionary<string, string> categories, Project project) { var projectTypes = project.GetTypeTags (); foreach (var type in projectTypes) { if (categories.ContainsKey (type)) return categories [type]; } return categories.ContainsKey (FileTemplate.DefaultCategoryKey) ? categories [FileTemplate.DefaultCategoryKey] : "Misc"; }
static string GetCategoryPropertyKey (Project proj) { string key = "Dialogs.NewFileDialog.LastSelectedCategory"; if (proj != null) { string projectType = proj.GetTypeTags ().FirstOrDefault (); if (projectType != null) { key += "." + projectType; var dnp = proj as DotNetProject; if (dnp != null) key += "." + dnp.LanguageName; } } return key; }
public override bool ShouldEnableFor (Project proj, string projectPath) { if (proj == null) return !requireExists; if (projectType != null && proj.GetTypeTags ().All (p => p != projectType)) return false; //check for permitted creation paths if (permittedCreationPaths != null) { bool noMatches = true; foreach (string path in permittedCreationPaths) { string matchPath = Path.Combine (proj.BaseDirectory, path); if (Path.GetFullPath (matchPath) == Path.GetFullPath (projectPath)) noMatches = false; } if (noMatches) return false; } //check for excluded creation paths if (excludedCreationPaths != null) { bool foundMatch = false; foreach (string path in excludedCreationPaths) { string matchPath = Path.Combine (proj.BaseDirectory, path); if (Path.GetFullPath (matchPath) == Path.GetFullPath (projectPath)) foundMatch = true; } if (foundMatch) return false; } //check for required files if (requiredFiles != null) { bool requiredFileNotFound = true; foreach (string f in requiredFiles) { string requiredFile = (f[0] == '/')? Path.Combine (proj.BaseDirectory, f.Substring(1)) : Path.Combine (projectPath, f); if (proj.Files.GetFile (requiredFile) != null) requiredFileNotFound = true; } if (requiredFileNotFound) return false; } //check for excluded files if (excludedFiles != null) { bool foundExcludedFile = false; foreach (string f in excludedFiles) { string excludedFile = (f[0] == '/')? Path.Combine (proj.BaseDirectory, f.Substring(1)) : Path.Combine (projectPath, f); if (proj.Files.GetFile (excludedFile) != null) foundExcludedFile = true; } if (foundExcludedFile) return false; } return true; }
protected virtual bool IsValidForProject (Project project, string projectPath) { // When there is no project, only single template files can be created. if (project == null) { foreach (FileDescriptionTemplate f in Files) if (!(f is SingleFileDescriptionTemplate)) return false; } // Filter on templates foreach (FileDescriptionTemplate f in Files) if (!f.SupportsProject (project, projectPath)) return false; //filter on conditions if (project != null) { if (!string.IsNullOrEmpty (ProjectType) && project.GetTypeTags ().All (p => p != ProjectType)) return false; foreach (FileTemplateCondition condition in Conditions) if (!condition.ShouldEnableFor (project, projectPath)) return false; } return true; }
/// <summary> /// Get the official project GUID/Type of MonoDevelops project kind. /// </summary> /// <param name="project">The MonoDevelop project to retrieve the project GUID/Type for.</param> /// <returns>Returns the official project GUID/Type.</returns> private string GetProjectKindOfProjectType(Project project) { Param.AssertNotNull(project, "projectType"); DotNetProject assemblyProject = project as DotNetProject; if (assemblyProject != null) { if (project.GetTypeTags().Where(name => name.Equals("AspNetApp", StringComparison.OrdinalIgnoreCase)).FirstOrDefault() != null && assemblyProject.LanguageName.Equals("C#", StringComparison.OrdinalIgnoreCase)) { return "{E24C65DC-7377-472b-9ABA-BC803B73C61A}"; } if (assemblyProject.LanguageName.Equals("C#", StringComparison.OrdinalIgnoreCase)) { return "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"; } } else { if (project.SupportedLanguages != null && project.SupportedLanguages.Length > 0 && project.SupportedLanguages.Contains("C#")) { return "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"; } } return "Unknown"; }
protected virtual bool IsValidForProject (Project project, string projectPath) { // When there is no project, only single template files can be created. if (project == null) { foreach (FileDescriptionTemplate f in Files) if (!(f is SingleFileDescriptionTemplate)) return false; } // Filter on templates foreach (FileDescriptionTemplate f in Files) if (!f.SupportsProject (project, projectPath)) return false; //filter on conditions if (project != null) { // When file template's project types don't match the current project's type. if (ProjectTypes.Any () && project.GetTypeTags ().All (p => !ProjectTypes.Contains (p))) return false; foreach (FileTemplateCondition condition in Conditions) if (!condition.ShouldEnableFor (project, projectPath)) return false; } return true; }