Ejemplo n.º 1
0
        private List <ExampleBase> GetChildren()
        {
            List <ExampleBase> children = new List <ExampleBase>();

            Type[]           types = AssemblyUtility.GetTypesRecursively(_namespace);
            HashSet <string> subNS = new HashSet <string>();

            foreach (var type in types)
            {
                if (type.Namespace == _namespace)
                {
                    ExampleBase child = Activator.CreateInstance(type) as ExampleBase;
                    if (child.IsContainedInTree)
                    {
                        children.Add(child);
                    }
                }
                else if (!subNS.Contains(type.Namespace))
                {
                    string ends = type.Namespace.Substring(this._namespace.Length + 1);
                    if (!string.IsNullOrEmpty(ends))
                    {
                        var nsItems   = ends.Split('.');
                        var currentNS = _namespace + "." + nsItems[0];
                        if (!subNS.Contains(currentNS))
                        {
                            children.Add(new FolderExample(currentNS));
                            subNS.Add(currentNS);
                        }
                        subNS.Add(type.Namespace);
                    }
                }
            }

            children.Sort(new ExampleComparer());

            return(children);
        }
Ejemplo n.º 2
0
        private ExampleBase FindExample(ExampleBase example, string id)
        {
            if (example.ID == id)
            {
                return(example);
            }

            FolderExample folderExample = example as FolderExample;

            if (folderExample != null)
            {
                foreach (var child in folderExample.Children)
                {
                    ExampleBase result = this.FindExample(child, id);
                    if (result != null)
                    {
                        return(result);
                    }
                }
            }

            return(null);
        }