private NamespaceDetail FindOrCreateNamespace(string ns)
        {
            if (ns == null)
            {
                ns = "*";
            }

            foreach (NamespaceDetail nsd in FilterChildren <NamespaceDetail>())
            {
                if (nsd.Name == ns)
                {
                    return(nsd);
                }
            }

            NamespaceDetail newns = new NamespaceDetail(this, ns);

            _children.Add(newns);
            return(newns);
        }
        public AssemblyDetail(Assembly assembly)
        {
            _name     = "";
            _location = assembly.Location;

            _children.Add(new TraitDetail(this, "FullName", assembly.FullName));
            _children.Add(new TraitDetail(this, "Version", assembly.GetName().Version.ToString()));
            _children.Add(new TraitDetail(this, "RuntimeVersion", assembly.ImageRuntimeVersion));
            _children.Add(new TraitDetail(this, "PublicKeyToken", GenericUtility.GetHashText(assembly.GetName().GetPublicKeyToken())));
            _children.Add(new TraitDetail(this, "Flags", assembly.GetName().Flags.ToString()));

            AttributesDetail attributes = new AttributesDetail(this);

            _children.Add(attributes);
            foreach (CustomAttributeData cad in CustomAttributeData.GetCustomAttributes(assembly))
            {
                AttributeDetail ad = new AttributeDetail(attributes, cad);
                ad.Visibility = Visibility.Exported;
                attributes.Children.Add(ad);
            }

            ResourcesDetail resources = new ResourcesDetail(this);

            _children.Add(resources);
            foreach (string resource in assembly.GetManifestResourceNames())
            {
                resources.Children.Add(new ResourceDetail(resources, resource, GenericUtility.ReadStream(assembly, resource)));
            }

            ReferencesDetail references = new ReferencesDetail(this);

            _children.Add(references);
            foreach (AssemblyName an in assembly.GetReferencedAssemblies())
            {
                references.Children.Add(new ReferenceDetail(references, an));
            }

            Type[] types = assembly.GetTypes();

            foreach (Type type in types)
            {
                try
                {
                    if (!type.IsNested)
                    {
                        NamespaceDetail ns = FindOrCreateNamespace(type.Namespace);

                        if (type.IsEnum)
                        {
                            ns.Children.Add(new EnumDetail(ns, type));
                        }
                        else if (type.IsInterface)
                        {
                            ns.Children.Add(new InterfaceDetail(ns, type));
                        }
                        else if (type.IsClass)
                        {
                            ns.Children.Add(new ClassDetail(ns, type));
                        }
                    }
                }
                catch (TypeLoadException tle)
                {
                    Log.Warn("Failed loading Type '{0}': {1}", type.FullName, tle.Message);
                }
            }
        }
Exemple #3
0
        private NamespaceDetail FindOrCreateNamespace(string ns)
        {
            if (ns == null)
            {
                ns = "*";
            }

            foreach (NamespaceDetail nsd in FilterChildren<NamespaceDetail>())
            {
                if (nsd.Name == ns)
                {
                    return nsd;
                }
            }

            NamespaceDetail newns = new NamespaceDetail(this, ns);
            _children.Add(newns);
            return newns;
        }