示例#1
0
        private void GenerateStructure(IClassContainer classContainer, LinkedList <TreeUIItem> parent)
        {
            foreach (var ilClass in classContainer.Classes.OrderBy(x => x.Name))
            {
                var item = new TreeUIItem()
                {
                    Header = ilClass.ShortName, Parent = ilClass, ItemType = ItemType.Class
                };

                // find a place for this class
                if (!ilClass.Name.Contains('.'))
                {
                    parent.AddLast(item);
                }
                else
                {
                    GetTreeUIItemForNamespace(ilClass.ParentAssembly, ilClass.Name, parent).Items.AddLast(item);
                }

                // add methods, properties and fields
                foreach (var unitKey in _unitNameToCollectionMap.Keys)
                {
                    var collection = _unitNameToCollectionMap[unitKey](ilClass);
                    if (!collection.Any())
                    {
                        continue;
                    }

                    var itemType = _unitKeyToItemTypeMap[unitKey];

                    // grouping item
                    var unitItem = new TreeUIItem()
                    {
                        Header = unitKey, ItemType = itemType
                    };
                    item.Items.AddLast(unitItem);

                    // all methods/properties/fields
                    foreach (var ilUnit in collection)
                    {
                        unitItem.Items.AddLast(new TreeUIItem()
                        {
                            Header = ilUnit.Name, Parent = ilUnit, ItemType = itemType
                        });
                    }
                }

                // add nested classes
                if (ilClass.Classes.Any())
                {
                    var nestedClassesItem = new TreeUIItem()
                    {
                        Header = "Nested classes", ItemType = ItemType.Class
                    };
                    item.Items.AddLast(nestedClassesItem);
                    GenerateStructure(ilClass, nestedClassesItem.Items); // recursive call for nested classes
                }
            }
        }
        private TreeUIItem GetTreeUIItemForNamespace(Assembly assembly, string _namespace, LinkedList<TreeUIItem> root)
        {
            string namespaceName = _namespace.Substring(0, _namespace.LastIndexOf('.'));
            string namespaceKey = String.Format("[{0}] {1}", assembly.FileName, namespaceName);

            if (!_namespaces.ContainsKey(namespaceKey))
            {
                _namespaces[namespaceKey] = new TreeUIItem() { Header = namespaceName, ItemType = ItemType.Namespace };
                root.AddLast(_namespaces[namespaceKey]);
            }

            return _namespaces[namespaceKey];
        }
示例#3
0
        private TreeUIItem GetTreeUIItemForNamespace(Assembly assembly, string _namespace, LinkedList <TreeUIItem> root)
        {
            string namespaceName = _namespace.Substring(0, _namespace.LastIndexOf('.'));
            string namespaceKey  = String.Format("[{0}] {1}", assembly.FileName, namespaceName);

            if (!_namespaces.ContainsKey(namespaceKey))
            {
                _namespaces[namespaceKey] = new TreeUIItem()
                {
                    Header = namespaceName, ItemType = ItemType.Namespace
                };
                root.AddLast(_namespaces[namespaceKey]);
            }

            return(_namespaces[namespaceKey]);
        }
示例#4
0
        public IList <TreeUIItem> GenerateTree(IEnumerable <Assembly> assemblies)
        {
            var items = new List <TreeUIItem>();

            foreach (var assembly in assemblies.OrderBy(x => x.FileName))
            {
                var item = new TreeUIItem()
                {
                    Header = assembly.FileName, ItemType = ItemType.Assembly
                };
                GenerateStructure(assembly, item.Items);
                items.Add(item);
            }

            return(items);
        }
        private void GenerateStructure(IClassContainer classContainer, LinkedList<TreeUIItem> parent)
        {
            foreach (var ilClass in classContainer.Classes.OrderBy(x => x.Name))
            {
                var item = new TreeUIItem() { Header = ilClass.ShortName, Parent = ilClass, ItemType = ItemType.Class };

                // find a place for this class
                if (!ilClass.Name.Contains('.'))
                {
                    parent.AddLast(item);
                }
                else
                {
                    GetTreeUIItemForNamespace(ilClass.ParentAssembly, ilClass.Name, parent).Items.AddLast(item);
                }

                // add methods, properties and fields
                foreach (var unitKey in _unitNameToCollectionMap.Keys)
                {
                    var collection = _unitNameToCollectionMap[unitKey](ilClass);
                    if (!collection.Any())
                    {
                        continue;
                    }

                    var itemType = _unitKeyToItemTypeMap[unitKey];

                    // grouping item
                    var unitItem = new TreeUIItem() { Header = unitKey, ItemType = itemType };
                    item.Items.AddLast(unitItem);

                    // all methods/properties/fields
                    foreach (var ilUnit in collection)
                    {
                        unitItem.Items.AddLast(new TreeUIItem() { Header = ilUnit.Name, Parent = ilUnit, ItemType = itemType });
                    }
                }

                // add nested classes
                if (ilClass.Classes.Any())
                {
                    var nestedClassesItem = new TreeUIItem() { Header = "Nested classes", ItemType = ItemType.Class };
                    item.Items.AddLast(nestedClassesItem);
                    GenerateStructure(ilClass, nestedClassesItem.Items); // recursive call for nested classes
                }
            }
        }
示例#6
0
 private void RemoveAssembly(TreeUIItem item)
 {
     Assemblies.Remove(item);
     _treeGenerator.RemoveAssembly(item.Header);
     _ilReader.Assemblies.Remove(_ilReader.Assemblies.FirstOrDefault(x => x.FileName == item.Header));
 }
        public IList<TreeUIItem> GenerateTree(IEnumerable<Assembly> assemblies)
        {
            var items = new List<TreeUIItem>();
            foreach (var assembly in assemblies.OrderBy(x => x.FileName))
            {
                var item = new TreeUIItem() { Header = assembly.FileName, ItemType = ItemType.Assembly };
                GenerateStructure(assembly, item.Items);
                items.Add(item);
            }

            return items;
        }
 private void RemoveAssembly(TreeUIItem item)
 {
     Assemblies.Remove(item);
     _treeGenerator.RemoveAssembly(item.Header);
     _ilReader.Assemblies.Remove(_ilReader.Assemblies.FirstOrDefault(x => x.FileName == item.Header));
 }