Ejemplo n.º 1
0
        TemplateCategory GetCategory(SolutionTemplate template, IEnumerable <TemplateCategory> currentCategories)
        {
            TemplateCategory match = null;

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

            var path = new TemplateCategoryPath(template.Category);

            foreach (string part in path.GetParts())
            {
                match = currentCategories.FirstOrDefault(category => category.IsMatch(part));

                if (match != null)
                {
                    currentCategories = match.Categories;
                }
                else
                {
                    return(null);
                }
            }

            return(match);
        }
		void SelectTemplateInCategory (string categoryPath, Func<SolutionTemplate, bool> isTemplateMatch)
		{
			List<string> parts = new TemplateCategoryPath (categoryPath).GetParts ().ToList ();
			if (parts.Count < 2) {
				return;
			}

			string topLevelCategoryId = parts [0];
			string secondLevelCategoryId = parts [1];
			SelectTemplate (
				isTemplateMatch,
				category => category.Id == topLevelCategoryId,
				category => category.Id == secondLevelCategoryId);
		}
		TemplateCategory GetCategory (SolutionTemplate template, IEnumerable<TemplateCategory> currentCategories)
		{
			TemplateCategory match = null;

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

			var path = new TemplateCategoryPath (template.Category);
			foreach (string part in path.GetParts ()) {
				match = currentCategories.FirstOrDefault (category => category.IsMatch (part));

				if (match != null) {
					currentCategories = match.Categories;
				} else {
					return null;
				}
			}

			return match;
		}
Ejemplo n.º 4
0
		void SelectFirstTemplateInCategory (string categoryPath)
		{
			List<string> parts = new TemplateCategoryPath (categoryPath).GetParts ().ToList ();
			if (parts.Count < 2) {
				return;
			}

			string topLevelCategoryId = parts [0];
			string secondLevelCategoryId = parts [1];
			SelectTemplate (
				template => true,
				category => category.Id == topLevelCategoryId,
				category => category.Id == secondLevelCategoryId);
		}