예제 #1
0
 static string GetCategoryPropertyKey(Project proj)
 {
     string key = "Dialogs.NewFileDialog.LastSelectedCategory";
     if (proj != null) {
         key += "." + proj.GetProjectTypes ().First ();
         var dnp = proj as DotNetProject;
         if (dnp != null)
             key += "." + dnp.LanguageName;
     }
     return key;
 }
예제 #2
0
		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.GetProjectTypes ().All (p => p != projecttype))
                    return false;

                foreach (FileTemplateCondition condition in conditions)
                    if (!condition.ShouldEnableFor (project, projectPath))
                        return false;
            }

            return true;
        }
        public override bool ShouldEnableFor(Project proj, string projectPath)
        {
            if (proj == null)
                return !requireExists;

            if (projectType != null && proj.GetProjectTypes ().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;
        }