void InitCollections() { nodeTypes = new ExtensionNodeTypeCollection(this); nodeSets = new NodeSetIdCollection(); foreach (XmlNode n in Element.ChildNodes) { XmlElement nt = n as XmlElement; if (nt == null) { continue; } if (nt.LocalName == "ExtensionNode") { ExtensionNodeType etype = new ExtensionNodeType(nt); nodeTypes.Add(etype); } else if (nt.LocalName == "ExtensionNodeSet") { string id = nt.GetAttribute("id"); if (id.Length > 0) { nodeSets.Add(id); } else { missingNodeSetId = true; } } } }
/// <summary> /// Gets all the allowed node types. /// </summary> /// <returns> /// The allowed node types. /// </returns> /// <remarks> /// Gets all allowed node types, including those defined in included node sets. /// This method only works for descriptions loaded from a registry. /// </remarks> public ExtensionNodeTypeCollection GetAllowedNodeTypes() { if (cachedAllowedTypes == null) { cachedAllowedTypes = new ExtensionNodeTypeCollection(); GetAllowedNodeTypes(new Hashtable(), cachedAllowedTypes); } return(cachedAllowedTypes); }
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 override void Read(BinaryXmlReader reader) { id = reader.ReadStringValue("Id"); nodeTypes = (ExtensionNodeTypeCollection)reader.ReadValue("NodeTypes", new ExtensionNodeTypeCollection(this)); reader.ReadValue("NodeSets", NodeSets.InternalList); }
internal void Clear() { Element = null; nodeSets = null; nodeTypes = null; }