public void RegisterNodeSet (AddinDescription description, ExtensionNodeSet nset) { List<RootExtensionPoint> extensions; if (nodeSetHash.TryGetValue (nset.Id, out extensions)) { // Extension point already registered List<ExtensionPoint> compatExtensions = GetCompatibleExtensionPoints (nset.Id, description, description.MainModule, extensions); if (compatExtensions.Count > 0) { foreach (ExtensionPoint einfo in compatExtensions) einfo.NodeSet.MergeWith (null, nset); return; } } // Create a new extension set RootExtensionPoint rep = new RootExtensionPoint (); rep.ExtensionPoint = new ExtensionPoint (); rep.ExtensionPoint.SetNodeSet (nset); rep.ExtensionPoint.RootAddin = description.AddinId; rep.ExtensionPoint.Path = nset.Id; rep.Description = description; if (extensions == null) { extensions = new List<RootExtensionPoint> (); nodeSetHash [nset.Id] = extensions; } extensions.Add (rep); }
void GetNodeTypes (AddinRegistry reg, ExtensionNodeSet nset, List<ExtensionNodeType> list) { foreach (ExtensionNodeType nt in nset.NodeTypes) list.Add (nt); foreach (string ns in nset.NodeSets) { ExtensionNodeSet cset = FindNodeSet (reg, nset.ParentAddinDescription, ns); if (cset != null) GetNodeTypes (reg, nset, list); } }
internal void MergeWith(string thisAddinId, ExtensionNodeSet other) { foreach (ExtensionNodeType nt in other.NodeTypes) { if (nt.AddinId != thisAddinId && !NodeTypes.Contains(nt)) { NodeTypes.Add(nt); } } NodeSets.MergeWith(thisAddinId, other.NodeSets); }
/// <summary> /// Copies data from another node set /// </summary> /// <param name='nset'> /// Node set from which to copy /// </param> public void CopyFrom (ExtensionNodeSet nset) { id = nset.id; NodeTypes.Clear (); foreach (ExtensionNodeType nt in nset.NodeTypes) { ExtensionNodeType cnt = new ExtensionNodeType (); cnt.CopyFrom (nt); NodeTypes.Add (cnt); } NodeSets.Clear (); foreach (string ns in nset.NodeSets) NodeSets.Add (ns); missingNodeSetId = nset.missingNodeSetId; }
public void RegisterAddinRootNodeSet (AddinDescription description, ExtensionNodeSet nodeSet) { ArrayList list = (ArrayList) nodeSetHash [nodeSet.Id]; if (list == null) { list = new ArrayList (); nodeSetHash [nodeSet.Id] = list; } RootExtensionPoint rep = new RootExtensionPoint (); rep.Description = description; ExtensionPoint ep = new ExtensionPoint (); ep.RootAddin = description.AddinId; ep.SetNodeSet (nodeSet); rep.ExtensionPoint = ep; list.Add (rep); }
/// <summary> /// Copies data from another node set /// </summary> /// <param name='nset'> /// Node set from which to copy /// </param> public void CopyFrom(ExtensionNodeSet nset) { id = nset.id; NodeTypes.Clear(); foreach (ExtensionNodeType nt in nset.NodeTypes) { ExtensionNodeType cnt = new ExtensionNodeType(); cnt.CopyFrom(nt); NodeTypes.Add(cnt); } NodeSets.Clear(); foreach (string ns in nset.NodeSets) { NodeSets.Add(ns); } missingNodeSetId = nset.missingNodeSetId; }
internal override void Read(BinaryXmlReader reader) { path = reader.ReadStringValue("path"); name = reader.ReadStringValue("name"); if (!reader.IgnoreDescriptionData) { description = reader.ReadStringValue("description"); } rootAddin = reader.ReadStringValue("rootAddin"); addins = (StringCollection)reader.ReadValue("addins", new StringCollection()); nodeSet = (ExtensionNodeSet)reader.ReadValue("NodeSet"); conditions = (ConditionTypeDescriptionCollection)reader.ReadValue("Conditions", new ConditionTypeDescriptionCollection(this)); if (nodeSet != null) { nodeSet.SetParent(this); } }
internal void MergeExternalData(AddinDescription other) { // Removes extension types and extension sets coming from other add-ins. foreach (ExtensionPoint ep in other.ExtensionPoints) { ExtensionPoint tep = ExtensionPoints [ep.Path]; if (tep != null) { tep.MergeWith(AddinId, ep); } } foreach (ExtensionNodeSet ns in other.ExtensionNodeSets) { ExtensionNodeSet tns = ExtensionNodeSets [ns.Id]; if (tns != null) { tns.MergeWith(AddinId, ns); } } }
void GetAllowedNodeTypes(Hashtable visitedSets, ExtensionNodeTypeCollection col) { if (Id.Length > 0) { if (visitedSets.Contains(Id)) { return; } visitedSets [Id] = Id; } // Gets all allowed node types, including those defined in node sets // It only works for descriptions generated from a registry foreach (ExtensionNodeType nt in NodeTypes) { col.Add(nt); } AddinDescription desc = ParentAddinDescription; if (desc == null || desc.OwnerDatabase == null) { return; } foreach (string[] ns in NodeSets.InternalList) { string startAddin = ns [1]; if (startAddin == null || startAddin.Length == 0) { startAddin = desc.AddinId; } ExtensionNodeSet nset = desc.OwnerDatabase.FindNodeSet(ParentAddinDescription.Domain, startAddin, ns[0]); if (nset != null) { nset.GetAllowedNodeTypes(visitedSets, col); } } }
internal void SetNodeSet(ExtensionNodeSet nset) { // Used only by the addin updater nodeSet = nset; nodeSet.SetParent (this); }
internal override void Read(BinaryXmlReader reader) { path = reader.ReadStringValue ("path"); name = reader.ReadStringValue ("name"); if (!reader.IgnoreDescriptionData) description = reader.ReadStringValue ("description"); rootAddin = reader.ReadStringValue ("rootAddin"); addins = (List<string>) reader.ReadValue ("addins", new List<string> ()); nodeSet = (ExtensionNodeSet) reader.ReadValue ("NodeSet"); conditions = (ConditionTypeDescriptionCollection) reader.ReadValue ("Conditions", new ConditionTypeDescriptionCollection (this)); defaultInsertBefore = reader.ReadStringValue ("defaultInsertBefore"); defaultInsertAfter = reader.ReadStringValue ("defaultInsertAfter"); if (nodeSet != null) nodeSet.SetParent (this); }
void PrintExtensionNodeSetXml(XmlWriter tw, AddinDescription desc, ExtensionNodeSet nset, ArrayList list, Hashtable visited) { foreach (ExtensionNodeType nt in nset.GetAllowedNodeTypes ()) { tw.WriteStartElement ("ExtensionNode"); tw.WriteAttributeString ("name", nt.Id); string id = RegisterNodeXml (nt, list, visited); tw.WriteAttributeString ("id", id.ToString ()); if (nt.Description.Length > 0) tw.WriteElementString ("Description", nt.Description); tw.WriteEndElement (); } }
void GetNodes(AddinDescription desc, ExtensionNodeSet nset, ArrayList list, Hashtable visited) { if (visited.Contains (nset)) return; visited.Add (nset, nset); foreach (ExtensionNodeType nt in nset.NodeTypes) { if (!visited.Contains (nt.Id + " " + nt.TypeName)) { list.Add (nt); visited.Add (nt.Id + " " + nt.TypeName, nt); } } foreach (string nsid in nset.NodeSets) { ExtensionNodeSet rset = desc.ExtensionNodeSets [nsid]; if (rset != null) GetNodes (desc, rset, list, visited); } }
internal void RegisterNodeSet(string addinId, ExtensionNodeSet nset) { nset.SourceAddinId = addinId; nodeSets [nset.Id] = nset; }
void ScanNodeType(IAssemblyReflector reflector, AddinDescription config, ExtensionNodeType nt, ArrayList assemblies, Hashtable internalNodeSets) { if (nt.TypeName.Length == 0) nt.TypeName = "Mono.Addins.TypeExtensionNode"; object ntype = FindAddinType (reflector, nt.TypeName, assemblies); if (ntype == null) return; // Add type information declared with attributes in the code ExtensionNodeAttribute nodeAtt = (ExtensionNodeAttribute) reflector.GetCustomAttribute (ntype, typeof(ExtensionNodeAttribute), true); if (nodeAtt != null) { if (nt.Id.Length == 0 && nodeAtt.NodeName.Length > 0) nt.Id = nodeAtt.NodeName; if (nt.Description.Length == 0 && nodeAtt.Description.Length > 0) nt.Description = nodeAtt.Description; if (nt.ExtensionAttributeTypeName.Length == 0 && nodeAtt.ExtensionAttributeTypeName.Length > 0) nt.ExtensionAttributeTypeName = nodeAtt.ExtensionAttributeTypeName; } else { // Use the node type name as default name if (nt.Id.Length == 0) nt.Id = reflector.GetTypeName (ntype); } // Add information about attributes object[] fieldAtts = reflector.GetCustomAttributes (ntype, typeof(NodeAttributeAttribute), true); foreach (NodeAttributeAttribute fatt in fieldAtts) { NodeTypeAttribute natt = new NodeTypeAttribute (); natt.Name = fatt.Name; natt.Required = fatt.Required; if (fatt.TypeName != null) natt.Type = fatt.TypeName; if (fatt.Description.Length > 0) natt.Description = fatt.Description; nt.Attributes.Add (natt); } // Check if the type has NodeAttribute attributes applied to fields. foreach (object field in reflector.GetFields (ntype)) { NodeAttributeAttribute fatt = (NodeAttributeAttribute) reflector.GetCustomAttribute (field, typeof(NodeAttributeAttribute), false); if (fatt != null) { NodeTypeAttribute natt = new NodeTypeAttribute (); if (fatt.Name.Length > 0) natt.Name = fatt.Name; else natt.Name = reflector.GetFieldName (field); if (fatt.Description.Length > 0) natt.Description = fatt.Description; natt.Type = reflector.GetFieldTypeFullName (field); natt.Required = fatt.Required; nt.Attributes.Add (natt); } } // Check if the extension type allows children by looking for [ExtensionNodeChild] attributes. // First of all, look in the internalNodeSets hashtable, which is being used as cache string childSet = (string) internalNodeSets [nt.TypeName]; if (childSet == null) { object[] ats = reflector.GetCustomAttributes (ntype, typeof(ExtensionNodeChildAttribute), true); if (ats.Length > 0) { // Create a new node set for this type. It is necessary to create a new node set // instead of just adding child ExtensionNodeType objects to the this node type // because child types references can be recursive. ExtensionNodeSet internalSet = new ExtensionNodeSet (); internalSet.Id = reflector.GetTypeName (ntype) + "_" + Guid.NewGuid().ToString (); foreach (ExtensionNodeChildAttribute at in ats) { ExtensionNodeType internalType = new ExtensionNodeType (); internalType.Id = at.NodeName; internalType.TypeName = at.ExtensionNodeTypeName; internalSet.NodeTypes.Add (internalType); } config.ExtensionNodeSets.Add (internalSet); nt.NodeSets.Add (internalSet.Id); // Register the new set in a hashtable, to allow recursive references to the // same internal set. internalNodeSets [nt.TypeName] = internalSet.Id; internalNodeSets [reflector.GetTypeAssemblyQualifiedName (ntype)] = internalSet.Id; ScanNodeSet (reflector, config, internalSet, assemblies, internalNodeSets); } } else { if (childSet.Length == 0) { // The extension type does not declare children. return; } // The extension type can have children. The allowed children are // defined in this extension set. nt.NodeSets.Add (childSet); return; } ScanNodeSet (reflector, config, nt, assemblies, internalNodeSets); }
internal void SetNodeSet(ExtensionNodeSet nset) { // Used only by the addin updater nodeSet = nset; nodeSet.SetParent(this); }
internal ExtensionNodeType FindType(ExtensionNodeSet nset, string name, string callingAddinId) { if (nset == null) return null; foreach (ExtensionNodeType nt in nset.NodeTypes) { if (nt.Id == name) return nt; } foreach (string ns in nset.NodeSets) { ExtensionNodeSet regSet = (ExtensionNodeSet) nodeSets [ns]; if (regSet == null) { ReportError ("Unknown node set: " + ns, callingAddinId, null, false); return null; } ExtensionNodeType nt = FindType (regSet, name, callingAddinId); if (nt != null) return nt; } return null; }
void Fill (TreeIter it, ExtensionNodeSet nset, Hashtable visited, bool isReference) { if (visited.Contains (nset)) return; visited [nset] = nset; foreach (ExtensionNodeType nt in nset.NodeTypes) { TreeIter cit; if (it.Equals (TreeIter.Zero)) cit = store.AppendValues (nt, "md-extension-node-type", nt.NodeName, nt.TypeName, nt.Description, isReference); else cit = store.AppendValues (it, nt, "md-extension-node-type", nt.NodeName, nt.TypeName, nt.Description, isReference); Fill (cit, nt, visited, isReference); } foreach (string ns in nset.NodeSets) { TreeIter cit; ExtensionNodeSet rns = FindNodeSet (ns); if (it.Equals (TreeIter.Zero)) cit = store.AppendValues (rns, "md-extension-node-set", ns, string.Empty, string.Empty, isReference); else cit = store.AppendValues (it, rns, "md-extension-node-set", ns, string.Empty, string.Empty, isReference); if (rns != null) Fill (cit, rns, visited, false); } }
internal void MergeWith (string thisAddinId, ExtensionNodeSet other) { foreach (ExtensionNodeType nt in other.NodeTypes) { if (nt.AddinId != thisAddinId && !NodeTypes.Contains (nt)) NodeTypes.Add (nt); } NodeSets.MergeWith (thisAddinId, other.NodeSets); }
bool GetNodeBranch (TreeIter parent, string name, ExtensionNodeSet nset, out TreeIter citer, out ExtensionNodeSet cset) { TreeIter iter; bool more; if (!parent.Equals (TreeIter.Zero)) more = store.IterChildren (out iter, parent); else more = store.GetIterFirst (out iter); if (more) { do { if (((string)store.GetValue (iter, ColLabel)) == name) { ExtensionNodeDescription node = (ExtensionNodeDescription) store.GetValue (iter, ColObject); ExtensionNodeType nt = nset.GetAllowedNodeTypes () [node.NodeName]; cset = nt; citer = iter; return true; } } while (store.IterNext (ref iter)); } citer = iter; cset = null; return false; }
void FillNodes (TreeIter iter, ExtensionNodeSet ns, ExtensionNodeDescriptionCollection nodes) { ExtensionNodeTypeCollection ntypes = ns.GetAllowedNodeTypes (); foreach (ExtensionNodeDescription node in nodes) { if (node.IsCondition) { FillNodes (iter, ns, nodes); continue; } string id = node.Id; ExtensionNodeType nt = ntypes [node.NodeName]; // The node can only be extended if it has an ID and if it accepts child nodes if (id.Length > 0 && (nt.NodeTypes.Count > 0 || nt.NodeSets.Count > 0)) { TreeIter citer = GetBranch (iter, id + " (" + nt.NodeName + ")", null); store.SetValue (citer, ColObject, node); store.SetValue (citer, ColShowCheck, true); store.SetValue (citer, ColChecked, false); FillExtensionNodeSet (citer, nt); FillNodes (citer, nt, node.ChildNodes); } } }
void FillExtensionNodeSet (TreeIter iter, ExtensionNodeSet ns) { // Add extension node types /* ExtensionNodeTypeCollection col = ns.GetAllowedNodeTypes (); foreach (ExtensionNodeType nt in col) { string nname; if (nt.Description.Length > 0) { nname = GLib.Markup.EscapeText (nt.NodeName) + "\n"; nname += "<small>" + GLib.Markup.EscapeText (nt.Description) + "</small>"; } else nname = GLib.Markup.EscapeText (nt.NodeName); store.AppendValues (iter, nname, nt, null, true, selection.Contains (nt), null, false, true); } */ }
public void RegisterNodeSet (AddinDescription description, ExtensionNodeSet nset) { string id = Addin.GetFullId (description.Namespace, nset.Id, description.Version); foreach (ExtensionPoint einfo in GetExtensionInfo (nodeSetHash, id, description, description.MainModule, false)) { if (einfo.RootAddin == null || database.AddinDependsOn (einfo.RootAddin, description.AddinId)) einfo.RootAddin = description.AddinId; einfo.NodeSet.MergeWith (null, nset); } }
void LoadModuleExtensionNodes (Extension extension, string addinId, ExtensionNodeSet nset, ArrayList loadedNodes) { // Now load the extensions ArrayList addedNodes = new ArrayList (); tree.LoadExtension (addinId, extension, addedNodes); RuntimeAddin ad = AddinManager.SessionService.GetAddin (addinId); if (ad != null) { foreach (TreeNode nod in addedNodes) { // Don't call OnAddinLoaded here. Do it when the entire extension point has been loaded. if (nod.ExtensionNode != null) loadedNodes.Add (nod); } } }
public void Fill (DotNetProject project, AddinRegistry registry, AddinDescription adesc, ExtensionNodeSet nset) { this.nodeSet = nset; this.registry = registry; this.adesc = adesc; this.project = project; Update (); }
internal string GetNodeTypeAddin(ExtensionNodeSet nset, string type, string callingAddinId) { ExtensionNodeType nt = FindType (nset, type, callingAddinId); if (nt != null) return nt.AddinId; else return null; }
void ScanNodeSet(IAssemblyReflector reflector, AddinDescription config, ExtensionNodeSet nset, ArrayList assemblies, Hashtable internalNodeSets) { foreach (ExtensionNodeType nt in nset.NodeTypes) ScanNodeType (reflector, config, nt, assemblies, internalNodeSets); }
internal void RegisterNodeSet(ExtensionNodeSet nset) { nodeSets [nset.Id] = nset; }
public void RegisterNodeSet (ExtensionNodeSet nset) { nodeSets [nset.Id] = nset; }
internal void UnregisterNodeSet(ExtensionNodeSet nset) { nodeSets.Remove (nset.Id); }