void ScanAssemblyContents(AddinDescription config, Assembly asm, ArrayList hostExtensionClasses, AddinScanResult scanResult) { // Get dependencies object[] deps = asm.GetCustomAttributes(typeof(AddinDependencyAttribute), false); foreach (AddinDependencyAttribute dep in deps) { AddinDependency adep = new AddinDependency(); adep.AddinId = dep.Id; adep.Version = dep.Version; config.MainModule.Dependencies.Add(adep); } // Get extension points object[] extPoints = asm.GetCustomAttributes(typeof(ExtensionPointAttribute), false); foreach (ExtensionPointAttribute ext in extPoints) { ExtensionPoint ep = config.AddExtensionPoint(ext.Path); ep.Description = ext.Description; ep.Name = ext.Name; ep.AddExtensionNode(ext.NodeName, ext.NodeType.FullName); } foreach (Type t in asm.GetTypes()) { if (Attribute.IsDefined(t, typeof(ExtensionAttribute))) { foreach (ExtensionAttribute eatt in t.GetCustomAttributes(typeof(ExtensionAttribute), false)) { string path; string nodeName; if (eatt.Path.Length == 0) { if (config.IsRoot) { // The extension point must be one of the defined by the assembly // Look for it later, when the assembly has been fully scanned. hostExtensionClasses.Add(t); continue; } else { path = GetBaseTypeNameList(t); if (path == "$") { // The type does not implement any interface and has no superclass. // Will be reported later as an error. path = "$" + t.FullName; } nodeName = "Type"; } } else { path = eatt.Path; nodeName = eatt.NodeName; } ExtensionNodeDescription elem = config.MainModule.AddExtensionNode(path, nodeName); if (eatt.Id.Length > 0) { elem.SetAttribute("id", eatt.Id); elem.SetAttribute("type", t.FullName); } else { elem.SetAttribute("id", t.FullName); } if (eatt.InsertAfter.Length > 0) { elem.SetAttribute("insertafter", eatt.InsertAfter); } if (eatt.InsertBefore.Length > 0) { elem.SetAttribute("insertbefore", eatt.InsertAfter); } } } else if (Attribute.IsDefined(t, typeof(TypeExtensionPointAttribute))) { foreach (TypeExtensionPointAttribute epa in t.GetCustomAttributes(typeof(TypeExtensionPointAttribute), false)) { ExtensionPoint ep; ExtensionNodeType nt = new ExtensionNodeType(); if (epa.Path.Length > 0) { ep = config.AddExtensionPoint(epa.Path); } else { ep = config.AddExtensionPoint(GetDefaultTypeExtensionPath(config, t)); nt.ObjectTypeName = t.FullName; } nt.Id = epa.NodeName; nt.TypeName = epa.NodeType.FullName; ep.NodeSet.NodeTypes.Add(nt); ep.Description = epa.Description; ep.Name = epa.Name; ep.RootAddin = config.AddinId; ep.SetExtensionsAddinId(config.AddinId); } } } }