private void CreateChildNodes()
        {
            if (this.Item.LanguageTypes != null)
            {
                LanguageTypeCollection languageTypes = this.Item.LanguageTypes;

                foreach (ILanguageType item in languageTypes)
                {
                    this.Nodes.Add(new LanguageTypeNode(item));
                }
            }
        }
Пример #2
0
        public CategoryCollection GetCategories()
        {
            if (this._categories != null && this._categories.Count > 0)
            {
                return(this._categories);
            }

            Logger.Info("Loading all categories available in the configured templates");
            IList <TemplateModelCollection> collections = null;

            if (_templateFilesCollection == null || _templateFilesCollection.Count == 0)
            {
                collections = GetTemplateCollections();
            }

            Logger.Debug(String.Format("Number of collections to parse => {0}", collections.Count));


            this._categories    = new CategoryCollection();
            this._languageTypes = new LanguageTypeCollection();

            foreach (TemplateModelCollection collection in collections)
            {
                Logger.Debug("\n-----------------------------------START TEMPLATE COLLECTION-----------------------------------");

                Logger.Debug(String.Format("Current collection in the iterator has {0} templates", collection.Count));

                foreach (ITemplate template in collection)
                {
                    Logger.Debug("\n_______________________________START TEMPLATE______________________________________________");
                    Logger.Debug(String.Format("Processing template '{0}' to get unique Categories & LanguageTypes", template.Name));

                    ProjectCollection projects = new ProjectCollection();

                    Logger.Debug(String.Format("Current template in the iterator has {0} projects", template.Projects.Count));
                    foreach (IType projectType in template.Projects)
                    {
                        IProject project = new Project();
                        project.Name = projectType.DisplayName;
                        project.Icon = projectType.IconPath;

                        Logger.Debug(String.Format("Project's ('{0}') absolute Icon path provided [{1}]", project.Name,
                                                   this.TemplatePath + projectType.IconPath));

                        Logger.Debug("Project Icon has been loaded successfully");

                        projects.Add(project);

                        Logger.Debug(String.Format("Project '{0}' has been added to project collection", project.Name));
                    }

                    if (this._categories.Count == 0)
                    {
                        Logger.Info("Categories collection is empty, adding new categories now");

                        ILanguageType langType = new LanguageType();
                        langType.Name     = template.LanguageType;
                        langType.Projects = projects;
                        Logger.Debug(String.Format("Found new LanguageType '{0}'", langType.Name));

                        ICategory category = new Category();
                        category.Name = template.Category;
                        category.LanguageTypes.Add(langType);
                        Logger.Debug(String.Format("Found new Category '{0}'", category.Name));

                        this._categories.Add(category);

                        Logger.Debug(String.Format("'{0}' LanguageType added to Category '{1}'", langType.Name, category.Name));
                        Logger.Debug(String.Format("{0} projects added to LanguageType '{1}'", projects.Count, langType.Name));
                    }
                    else
                    {
                        bool isCategoryAlreadyExist = this._categories.Contains(template.Category);

                        if (isCategoryAlreadyExist)
                        {
                            ICategory category = this._categories.find(template.Category);
                            bool      isLangTypeAlreadyExist = category.LanguageTypes.Contains(template.LanguageType);

                            if (isLangTypeAlreadyExist)
                            {
                                ILanguageType langType = category.LanguageTypes.find(template.LanguageType);
                                langType.Projects.AddRange(projects);
                                Logger.Debug(String.Format("{0} projects added to LanguageType '{1}'", projects.Count, langType.Name));
                            }
                            else
                            {
                                ILanguageType langType = new LanguageType();
                                langType.Name     = template.LanguageType;
                                langType.Projects = projects;

                                Logger.Debug(String.Format("Found new LanguageType '{0}'", langType.Name));

                                category.LanguageTypes.Add(langType);

                                Logger.Debug(String.Format("'{0}' LanguageType added to Category '{1}'", langType.Name, category.Name));
                                Logger.Debug(String.Format("{0} projects added to LanguageType '{1}'", projects.Count, langType.Name));
                            }
                        }
                        else
                        {
                            ILanguageType langType = new LanguageType();
                            langType.Name     = template.LanguageType;
                            langType.Projects = projects;

                            Logger.Debug(String.Format("Found new LanguageType '{0}'", langType.Name));

                            ICategory category = new Category();
                            category.Name = template.Category;

                            Logger.Debug(String.Format("Found new Category '{0}'", category.Name));

                            category.LanguageTypes.Add(langType);

                            this._categories.Add(category);
                            Logger.Debug(String.Format("'{0}' LanguageType added to Category '{1}'", langType.Name, category.Name));
                            Logger.Debug(String.Format("{0} projects added to LanguageType '{1}'", projects.Count, langType.Name));
                        }
                    }
                    Logger.Debug("_______________________________END TEMPLATE______________________________________________\n");
                }
                Logger.Debug("-----------------------------------END TEMPLATE COLLECTION-----------------------------------\n");
            }
            return(this._categories);
        }