/// <summary> /// Creates the GUI from a tag definition and a loaded tag object. /// </summary> public void Create(XmlDocument tagDefinitionDocument, Types.IBlock tagData) { try { this.tagData = tagData; this.tagDefinition = tagDefinitionDocument; // Check to see if this is a derived type. XmlNode nameNode = tagDefinitionDocument.SelectSingleNode("//name"); string parentClass = nameNode.Attributes["parenttype"].InnerText; if ((parentClass != "") && (parentClass != "????")) { XmlDocument tempDefinitionStorage = this.tagDefinition; XmlDocument parentDefinition = TagDefinitionManager.GetTagDefinition(parentClass); Create(parentDefinition, this.tagData); this.tagDefinition = tempDefinitionStorage; } mainStructName = nameNode.InnerText; XmlNode mainNode = tagDefinition.SelectSingleNode("//struct[@name='" + mainStructName + "']"); // If it's not there, then this object doesn't match the supplied tag definition. if (mainNode == null) { throw new Exception("'" + mainStructName + "' node was not found in the tag definition."); } className = tagDefinition.SelectSingleNode("//xml/name").InnerText; buildDepth.Push(0); string tabName = mainNode.Attributes["name"].InnerText; if (mainNode.Attributes["caption"] != null) { tabName = mainNode.Attributes["caption"].InnerText; } CreateTab(tabName); BlockContainer container = BuildStruct(mainNode, true); container.DatabindChildrenToBlock(this.tagData); containers.Peek().AddFieldContainer(container); buildDepth.Pop(); } catch (Exception ex) { throw new Exception("Could not load tag into TagEditor: " + ex.Message); } }
public DependencyBuilder(TagFileName tagFile) { // Load the proper tag definition. XmlDocument tagDefinition = TagDefinitionManager.GetTagDefinitionByName(tagFile.FileExtension); // Load the tag data TagBase tag = new TagBase(); tag.LoadTagBuffer(tagFile); BinaryReader br = new BinaryReader(tag.Stream); // Create the appropriate type. XmlNode nameNode = tagDefinition.SelectSingleNode("//name"); string tagTypeString = "TagLibrary.Halo1." + nameNode.InnerText; Assembly a = Assembly.GetAssembly(typeof(IField)); IBlock tagBlock = (a.CreateInstance(tagTypeString) as IBlock); tagBlock.Read(br); tagBlock.ReadChildData(br); Dependencies = ProcessDependencies(tagBlock); }