// データの取得 // データのロード public void AddData(HtmlAttributeGroup heg){ Object[] data = new Object[]{null, heg.Id, heg.Name, heg}; DataRow row = this.NewRow(); row.ItemArray = data; this.Rows.Add(row); }
protected XmlNode GetCommonAttributeInfo(HtmlAttributeGroup[] attrGroups){ if(attrGroups == null || attrGroups.Length == 0) return Html.Null; XmlNode result = Html.P(); result.InnerText = "共通属性 …… "; result.AppendChild(GetHtmlItemList(attrGroups, ", ")); return result; }
/// <summary> /// 指定された XML ファイルからデータをロードします。 /// この処理はスレッドセーフではありません。 /// </summary> public void Load(){ XmlNodeList elems = Document.DocumentElement[ElementsRefName].GetElementsByTagName(ElementElementName); XmlNodeList elemGroups = Document.DocumentElement[ElementsRefName].GetElementsByTagName(ElementGroupElementName); XmlNodeList attrs = Document.DocumentElement[AttributesRefName].GetElementsByTagName(AttributeElementName); XmlNodeList attrGroups = Document.DocumentElement[AttributesRefName].GetElementsByTagName(AttributeGroupElementName); XmlNodeList datas = Document.DocumentElement[DataRefName].GetElementsByTagName(DataFormatElementName); HtmlElement[] he = new HtmlElement[elems.Count]; for(int i=0; i < elems.Count; i++){he[i] = new HtmlElement(elems[i] as XmlElement);} HtmlElementGroup[] heg = new HtmlElementGroup[elemGroups.Count]; for(int i=0; i < elemGroups.Count; i++){heg[i] = new HtmlElementGroup(elemGroups[i] as XmlElement);} HtmlAttribute[] ha = new HtmlAttribute[attrs.Count]; for(int i=0; i < attrs.Count; i++){ha[i] = new HtmlAttribute(attrs[i] as XmlElement);} HtmlAttributeGroup[] hag = new HtmlAttributeGroup[attrGroups.Count]; for(int i=0; i < attrGroups.Count; i++){hag[i] = new HtmlAttributeGroup(attrGroups[i] as XmlElement);} HtmlData[] hd = new HtmlData[datas.Count]; for(int i=0; i < datas.Count; i++){hd[i] = new HtmlData(datas[i] as XmlElement);} ElementTable.MinimumCapacity = he.Length; Array.ForEach(he, item=>{ElementTable.AddData(item);}); ElementGroupTable.MinimumCapacity = heg.Length; Array.ForEach(heg, item=>{ElementGroupTable.AddData(item);}); AttributeTable.MinimumCapacity = ha.Length; Array.ForEach(ha, item=>{AttributeTable.AddData(item);}); AttributeGroupTable.MinimumCapacity = hag.Length; Array.ForEach(hag, item=>{AttributeGroupTable.AddData(item);}); DataTable.MinimumCapacity = hd.Length; Array.ForEach(hd, item=>{DataTable.AddData(item);}); // 属性や親子関係を取得 Array.ForEach(he, item=>{SetChildren(item);SetAttribute(item);}); Array.ForEach(heg, item=>{SetChildren(item);}); Array.ForEach(ha, item=>{SetChildren(item);}); Array.ForEach(hag, item=>{SetChildren(item);}); }
// 属性値を解析して格納します。 // 親として関連づけます。 private void SetChildren(HtmlAttributeGroup hag){ List<HtmlAttribute> attrs = new List<HtmlAttribute>(); foreach(XmlElement e in hag.XmlElement.GetElementsByTagName(AttributesElementName)){ if(e == null) continue; string s = e.GetInnerText(); HtmlAttribute ha = GetAttribute(s); attrs.Add(ha); ha.AddParent(hag); } hag.Attributes = attrs.ToArray(); }
// Row[] を HtmlAttributeGroup[] に変換します。 private HtmlAttributeGroup[] DataRowsToHtmlAttributeGroup(DataRow[] rows){ HtmlAttributeGroup[] result = new HtmlAttributeGroup[rows.Length]; for(int i = 0; i < rows.Length; i++){ result[i] = GetHtmlAttributeGroup(rows[i]); } return result; }