Exemple #1
0
        /// <summary>
        /// Looks at the SelectedTemplate first to find a template that should be conditionally
        /// used. If there is no match then all templates in the same category that have the
        /// same template id are checked. This allows multiple templates with the same id in the
        /// same category to be supported. .NET Core 2.0 and .NET Core 1.0 project templates
        /// currently use the same template id so only one item is shown in the recently used
        /// items list but use different templates.
        /// </summary>
        SolutionTemplate GetConditionalTemplateForProcessing()
        {
            string language = GetLanguageForTemplateProcessing();

            SolutionTemplate template = SelectedTemplate.GetTemplate(language, finalConfigurationPage.Parameters);

            if (template != null)
            {
                return(template);
            }

            // Fallback to checking all templates that match the template id in the same category
            // and support the condition.
            SolutionTemplate matchedTemplate = TemplatingService.GetTemplate(
                templateCategories,
                currentTemplate => IsTemplateMatch(currentTemplate, SelectedTemplate, language, finalConfigurationPage.Parameters),
                category => true,
                category => true);

            if (matchedTemplate != null)
            {
                return(matchedTemplate.GetTemplate(language, finalConfigurationPage.Parameters));
            }

            return(null);
        }
Exemple #2
0
 static bool IsTemplateMatch(SolutionTemplate template, SolutionTemplate templateToMatch, string language, ProjectCreateParameters parameters)
 {
     return(template.Id == templateToMatch.Id &&
            template.Category == templateToMatch.Category &&
            template.GetTemplate(language, parameters) != null);
 }