Ejemplo n.º 1
0
        public System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            this.InitAssemblyCache();
            List <BaseItem> items = new List <BaseItem>();

            BaseItem      parentItem          = treePath.LastNode as BaseItem;
            TypeItem      parentTypeItem      = parentItem as TypeItem;
            NamespaceItem parentNamespaceItem = parentItem as NamespaceItem;

            Type   parentType = parentTypeItem != null ? parentTypeItem.TypeInfo : this.baseType;
            string parentName = parentNamespaceItem != null ? parentNamespaceItem.Name : null;

            if (this.showNamespaces && parentTypeItem == null)
            {
                foreach (string subName in this.GetSubNamespaces(parentName))
                {
                    items.Add(new NamespaceItem(subName, parentItem));
                }
            }
            if (!this.showNamespaces || parentName != null)
            {
                foreach (Assembly assembly in this.assemblies)
                {
                    foreach (Type exportedType in assembly.GetExportedTypes())
                    {
                        if (this.showNamespaces && exportedType.Namespace != parentName)
                        {
                            continue;
                        }
                        if (!parentType.IsAssignableFrom(exportedType))
                        {
                            continue;
                        }
                        if (parentType == exportedType)
                        {
                            continue;
                        }
                        if (this.filter != null && !this.filter(exportedType))
                        {
                            continue;
                        }
                        items.Add(new TypeItem(exportedType, parentItem));
                    }
                }
            }

            return(items);
        }
Ejemplo n.º 2
0
        public System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            this.InitAssemblyCache();
            List <BaseItem> items = new List <BaseItem>();

            BaseItem      parentItem          = treePath.LastNode as BaseItem;
            TypeItem      parentTypeItem      = parentItem as TypeItem;
            NamespaceItem parentNamespaceItem = parentItem as NamespaceItem;

            Type   parentType = parentTypeItem != null ? parentTypeItem.TypeInfo : this.baseType;
            string parentName = parentNamespaceItem != null ? parentNamespaceItem.Name : null;

            if (this.showNamespaces && parentTypeItem == null)
            {
                foreach (string subName in this.GetSubNamespaces(parentName))
                {
                    items.Add(new NamespaceItem(subName, parentItem));
                }
            }
            if (!this.showNamespaces || parentName != null)
            {
                foreach (Assembly assembly in this.assemblies)
                {
                    foreach (Type exportedType in assembly.GetExportedTypes())
                    {
                        if (this.showNamespaces && exportedType.Namespace != parentName)
                        {
                            continue;
                        }
                        if (exportedType.BaseType != parentType && (!parentType.IsInterface || !exportedType.GetInterfaces().Contains(parentType)))
                        {
                            continue;
                        }
                        if (this.filter != null && !this.filter(exportedType))
                        {
                            continue;
                        }
                        items.Add(new TypeItem(exportedType, parentItem));
                    }
                }
            }

            items.Sort((nodeOne, nodeTwo) => String.Compare(nodeOne.Name, nodeTwo.Name, StringComparison.Ordinal));
            return(items);
        }