Esempio n. 1
0
        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)
            {
                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));
                    }
                }
            }
        }
        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);
                }
            }
        }