Exemple #1
0
 public static Catalog Load()
 {
     Catalog catalog = new Catalog();
     Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
     foreach(Assembly assembly in assemblies) {
         Type[] types = assembly.GetTypes();
         foreach(Type type in types) {
             object[] attributes =
                 type.GetCustomAttributes(typeof(CodeBaseActionAttribute), false);
             if(attributes.Length > 0) {
                 CodeBaseActionAttribute attribute = (CodeBaseActionAttribute)attributes[0];
                 catalog.Add(new CodeBaseActionProxy(type), attribute.Category);
             }
         }
     }
     catalog.BuildSortedList();
     return catalog;
 }
        private void LoadCatalog()
        {
            trvActions.Nodes.Clear();
            _catalog = Catalog.Load();

            ActionNode showParseResults = new ActionNode("Show parse results",
                "Re-displays the list of passing/failing files from the last 'Parse All'.",
                ShowParseResultsInTree);
            trvActions.Nodes.Add(showParseResults);

            foreach (Category category in _catalog.Categories)
            {
                ActionNode categoryNode = new ActionNode(category.CategoryType.ToString(),
                    category.Description, null);
                trvActions.Nodes.Add(categoryNode);
                foreach (CodeBaseActionProxy item in category.Items)
                {
                    ActionNode itemNode = CreateActionNode(item);
                    categoryNode.Nodes.Add(itemNode);
                }
            }

            trvActions.SelectedNode = trvActions.Nodes[0];
        }