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);
        }
        public SolutionTemplate GetSelectedTemplateForSelectedLanguage()
        {
            if (SelectedTemplate != null)
            {
                SolutionTemplate languageTemplate = SelectedTemplate.GetTemplate(SelectedLanguage);
                if (languageTemplate != null)
                {
                    return(languageTemplate);
                }
            }

            return(SelectedTemplate);
        }
 SolutionTemplate GetTemplateForProcessing()
 {
     if (SelectedTemplate.HasCondition)
     {
         string           language = GetLanguageForTemplateProcessing();
         SolutionTemplate template = SelectedTemplate.GetTemplate(language, finalConfigurationPage.Parameters);
         if (template != null)
         {
             return(template);
         }
         throw new ApplicationException(String.Format("No template found matching condition '{0}'.", SelectedTemplate.Condition));
     }
     return(GetSelectedTemplateForSelectedLanguage());
 }
        protected override string UpdateNameFromSelectedTemplate()
        {
            var selectedTemplate = SelectedTemplate?.GetTemplate() as TemplateAssetDescription;

            if (selectedTemplate == null || !selectedTemplate.RequireName)
            {
                return(null);
            }

            // If the mount point of the current folder does not support this type of asset, try to select the first mount point that support it.
            var assetType = selectedTemplate.GetAssetType();

            TargetDirectory = AssetViewModel.FindValidCreationLocation(assetType, CurrentDirectory);
            if (TargetDirectory == null)
            {
                return(null);
            }

            var baseName = selectedTemplate.DefaultOutputName ?? selectedTemplate.AssetTypeName;
            var name     = NamingHelper.ComputeNewName(baseName, TargetDirectory.Assets, x => x.Name, "{0}{1}");

            return(name);
        }