Ejemplo n.º 1
0
 public NewProjectDialogViewModel()
 {
     ProjectTypeRegistry.TypesChanged += OnProjectsChanged;
     foreach (KeyValuePair <string, ProjectType> typePair in ProjectTypeRegistry.RegisteredTypes)
     {
         if (typePair.Key == typePair.Value.ID)
         {
             if (!ProjectTypes.Contains(typePair.Value))
             {
                 ProjectTypes.Add(typePair.Value);
             }
         }
     }
     ProjectLocation = Workspace.DefaultProjectDirectory;
 }
Ejemplo n.º 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)
            {
                // 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);
        }