Example #1
0
 public TemplateProcessor(
     CustomSolutionTemplate template,
     NewProjectConfiguration config,
     SolutionFolder parentFolder)
 {
     this.template     = template;
     this.config       = config;
     this.parentFolder = parentFolder;
 }
Example #2
0
 public Task <TemplateCreationResult> Create(
     CustomSolutionTemplate template,
     NewProjectConfiguration config,
     IReadOnlyDictionary <string, string> parameters)
 {
     return(templateCreator.InstantiateAsync(
                template.Info,
                config.ProjectName,
                config.GetValidProjectName(),
                config.ProjectLocation,
                parameters,
                true,
                false,
                null
                ));
 }
Example #3
0
        public void LoadTemplates()
        {
            if (loaded || !TemplatingServices.Options.TemplateFolders.Any())
            {
                return;
            }

            EnsureInitialized();

            var settingsLoader = (SettingsLoader)settings.SettingsLoader;

            foreach (string folder in TemplatingServices.Options.TemplateFolders)
            {
                if (Directory.Exists(folder))
                {
                    try {
                        settingsLoader.UserTemplateCache.Scan(folder);
                    } catch (Exception ex) {
                        string message = string.Format("Unable to load templates from folder '{0}.", folder);
                        TemplatingServices.LogError(message, ex);
                    }
                }
            }

            // If there are no templates found then do not save the settings. This
            // avoids a null reference exception in the settingsLoader.Save method.
            if (!settingsLoader.MountPoints.Any())
            {
                loaded = true;
                return;
            }

            settingsLoader.Save();
            paths.WriteAllText(paths.User.FirstRunCookie, string.Empty);

            foreach (TemplateInfo templateInfo in settingsLoader.UserTemplateCache.TemplateInfo)
            {
                var template = new CustomSolutionTemplate(templateInfo);
                templates.Add(template);
            }

            loaded = true;
        }