public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false) { if (rootNode == null) { return; } XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this); XmlNodeList children; children = XmlGetter.Children(rootNode, "Item"); if (children != null) { foreach (XmlNode child in children) { String name = XmlGetter.Attribute(child, "Name"); if (name.Length > 0) { _items.Add(name, child.InnerText.Trim()); } //if (child != null) _items = child.InnerText; } } /* * child = XmlGetter.Child(rootNode, "ColumnName"); * if (child != null) _columnName = child.InnerText; * * child = XmlGetter.Child(rootNode, "RowName"); * if (child != null) _rowName = child.InnerText; * * child = XmlGetter.Child(rootNode, "Enabled"); * if (child != null) _enabled = child.InnerText; */ }
public static void LoadInterface(IXmlItem xmlComponent, XmlNode rootNode, XmlDocument document) { if (xmlComponent.Interface == null) { xmlComponent.Interface = new XmlItemInterface(rootNode, document, xmlComponent); } if (rootNode == null) { return; } NowEventLoadingXmlItem = xmlComponent; //Action에서 각각의 type에 따라서 적절한 Condition을 가져오기 위해 사용됨.. XmlNode xEvents = XmlGetter.Child(rootNode, "Events"); // rootNode.SelectSingleNode("Events"); if (xEvents != null) { xmlComponent.Interface.Events.LoadXml(document, xEvents); } XmlNodeList xArguments = XmlGetter.Children(rootNode, "Arguments/Argument"); if (xArguments != null) { foreach (XmlNode xArg in xArguments) { String name = XmlGetter.Attribute(xArg, "Name"); String value = xArg.InnerText; xmlComponent.Interface.Arguments.Add(name, value); } } }
public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false) { if (rootNode == null) { return; } _xDoc = xDoc; XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this); try { XmlNode infoNode = XmlGetter.Child(rootNode, "Info"); _info.LoadXml(xDoc, infoNode, refLoad); } catch (Exception e) { throw new Exception("Error On Loading Template [" + _filePath + "].Info.." + e.Message); } try { XmlNode commandNode = XmlGetter.Child(rootNode, "Command"); if (commandNode != null) { _command = new XmlCommandStructDefinition("CommandHeader.xml", StructType.Command); _command.LoadXml(_xDoc, commandNode); } } catch (Exception e) { throw new Exception("Error on Loading Template [" + _info.Name + "].Command..." + e.Message); } try { XmlNodeList responseNodeList = XmlGetter.Children(rootNode, "Response"); foreach (XmlNode responseNode in responseNodeList) { String type = XmlGetter.Attribute(responseNode, "Type"); if (type.ToLower().Equals("continuous")) { _autoResponse = new XmlCommandStructDefinition("ResponseHeader.xml", StructType.Response); _autoResponse.LoadXml(_xDoc, responseNode); } else { _response = new XmlCommandStructDefinition("ResponseHeader.xml", StructType.Response); _response.LoadXml(_xDoc, responseNode); } } } catch (Exception e) { throw new Exception("Error on Loading Template [" + _info.Name + "].Response..." + e.Message); } }
public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false) { if (rootNode == null) { return; } _xDoc = xDoc; XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this); XmlNodeList fields = XmlGetter.Children(rootNode, "Field"); int count = 0; foreach (XmlNode field in fields) { XmlCommandField xField = new XmlCommandField(null); xField.LoadXml(xDoc, field, refLoad); FieldList.Add(xField.Name, xField); if (xField.FieldType == FieldTypes.DataSize) { _dataSizeField = xField; } else if (xField.Name.ToLower().Equals("id")) { _idField = xField; } else if (xField.Name.ToLower().Equals("tag")) { _tagField = xField; } addItem(count++, xField.DataSize, true); } setBuffSize(); int offset = 0; foreach (XmlCommandField field in FieldList.Values) { field.SetTargetBuffer(this.buffer, offset); field.Data = field.Data; offset += field.DataSize; } /* * XmlCommandFields xmlFields = new XmlCommandFields(null); * xmlFields.LoadXml(xDoc, fields, refLoad); */ }
public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false) { if (rootNode == null) { return; } _xDoc = xDoc; XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this); NowLoading = this; XmlNode commonMatchItem = XmlGetter.Child(rootNode, "CommonMatches"); XmlMatchItem commonMatches = new XmlMatchItem(); commonMatches.LoadXml(xDoc, commonMatchItem); XmlNodeList matchItems = XmlGetter.Children(rootNode, "MatchItem"); foreach (XmlNode matchItem in matchItems) { String targetTemplate = XmlGetter.Attribute(matchItem, "TargetTemplate"); if (targetTemplate.Length == 0) { throw new Exception("MatchItem Tag에 TargetTemplate 속성이 없습니다."); } XmlMatchItem item = new XmlMatchItem(); item.LoadXml(xDoc, matchItem); foreach (XmlMatchData matchData in commonMatches.GetMatchDataList(XmlMatchItem.ActiveTimes.Init)) { item.GetMatchDataList(XmlMatchItem.ActiveTimes.Init).Add(matchData); } foreach (XmlMatchData matchData in commonMatches.GetMatchDataList(XmlMatchItem.ActiveTimes.Send)) { item.GetMatchDataList(XmlMatchItem.ActiveTimes.Send).Add(matchData); } foreach (XmlMatchData matchData in commonMatches.GetMatchDataList(XmlMatchItem.ActiveTimes.Recv)) { item.GetMatchDataList(XmlMatchItem.ActiveTimes.Recv).Add(matchData); } _matchItems.Add(targetTemplate, item); } }
public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false) { if (rootNode == null) { return; } _xDoc = xDoc; XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this); XmlNodeList fieldNodeList = XmlGetter.Children(rootNode, "Fields/Field"); int count = 0; int index = 0; foreach (XmlNode fieldNode in fieldNodeList) { XmlField field = new XmlField(new byte[1], count); field.LoadXml(xDoc, fieldNode); _fields.Add(field.Name, field); if (field.Count > 1) { for (int i = 0; i < field.Count; i++) { addItem(index++, field.DataTypeSize, true); } } else { addItem(index++, field.DataTypeSize, true); } count += field.Count * field.DataTypeSize; } setBuffSize(); //size를 fix함.. for (int i = 0; i < _fields.Values.Count; i++) { _fields.Values.ElementAt(i).TargetBuffer = this.buffer; _fields.Values.ElementAt(i).Data = _fields.Values.ElementAt(i).Data;//실제 값을 넣어준다. } }
public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false) { if (rootNode == null) { return; } XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this); string name = XmlGetter.Attribute(rootNode, "Name"); //string realTimeArgs = XmlGetter.Attribute(rootNode, "IsRealTimeArgs"); Name = name; //IsRealTimeArgs = ValueParser.IsTrue(realTimeArgs); XmlNodeList argList = XmlGetter.Children(rootNode, "Arg"); //Arg로 하나씩 나누었을 때 if (argList.Count == 0) { XmlNode node = XmlGetter.Child(rootNode, "Args");//Args로 빈칸으로 구분하여 넣었을 때 if (node != null) { string[] args = node.InnerText.Split(" ,".ToCharArray()); Args = args; } } else { List <String> args = new List <string>(); foreach (XmlNode node in argList) { args.Add(node.InnerText); } Args = args.ToArray(); } }
public static List <CPacketItem> XmlToItems(String xmlFile, CStructInfo info = null) { List <CPacketItem> items = new List <CPacketItem>(); XmlDocument xDoc = new XmlDocument(); xDoc.Load(xmlFile); XmlNodeList xNodeList; if (info != null) { xNodeList = xDoc.SelectNodes("//Packet//Infos//Info"); for (int i = 0; i < xNodeList.Count; i++) { String name = xNodeList.Item(i).Attributes["Name"].Value; String value = xNodeList.Item(i).InnerText; switch (name) { case "Comment": info.Comment = value; break; case "LastModified": info.SetModified(value); break; } } } xNodeList = xDoc.SelectNodes("//Packet//Items//Item"); for (int i = 0; i < xNodeList.Count; i++) { String name = xNodeList.Item(i).Attributes["Name"].Value; String type = xNodeList.Item(i).Attributes["Type"].Value; bool isSwap = false; try { isSwap = xNodeList.Item(i).Attributes["IsSwap"].Value.ToLower().Equals("true"); } catch { } int size = 0; try{ size = Convert.ToInt32(xNodeList.Item(i).Attributes["Size"].Value); }catch {} XmlNodeList initValues = XmlGetter.Children(xNodeList.Item(i), "InitValue"); // xNodeList.Item(i).ChildNodes; CPacketItem item = new CPacketItem(name, type, size, "0", null); //default if (initValues.Count > 1) { if (size == 0) { size = initValues.Count; //size가 지정되지 않았으면 초기설정개수와 동일하게 맞춘다. } List <String> initObjValues = new List <String>(); if (initValues.Count <= size) //정해진 배열크기보다 초기값설정이 적거나 일치할 때 { for (int initCount = 0; initCount < initValues.Count; initCount++) //초기설정을 넣는다. { if (initValues.Item(initCount).Name.Equals("InitValue")) { initObjValues.Add(initValues.Item(initCount).InnerText); } } for (int initCount = initValues.Count; initCount < size; initCount++)//초기설정이 모자라면 0으로 채운다. { if (initValues.Item(initCount).Name.Equals("InitValue")) { initObjValues.Add("0"); } } } else//초기설정값이 더 많을 때.. { for (int initCount = 0; initCount < size; initCount++) //초기설정을 size에서 정해진 만큼만 넣는다. { if (initValues.Item(initCount).Name.Equals("InitValue")) { initObjValues.Add(initValues.Item(initCount).InnerText); } } } item = new CPacketItem(name, type, size, initObjValues.ToArray()); } XmlNode function = XmlGetter.Child(xNodeList.Item(i), "Function");// xNodeList.Item(i).ChildNodes; if (function != null) { FunctionInfo func = new FunctionInfo(); if (initValues.Item(0).Name.Equals("Function")) { XmlNodeList args = initValues.Item(0).ChildNodes; List <String> argList = new List <string>(); String funcName = initValues.Item(0).Attributes["Name"].Value; for (int argc = 0; argc < args.Count; argc++) { argList.Add(args[argc].InnerText); } String[] argArray; if (argList.Count > 0) { argArray = argList.ToArray(); } else { argArray = null; } if (FunctionsList.ContainsKey(funcName)) { func = new FunctionInfo(FunctionsList[funcName], argArray); } else { func = new FunctionInfo(funcName, null, argArray); // } } if (func.Exists) { item = new CPacketItem(name, type, size, func, null); } else { String initObj = initValues.Item(0).InnerText; item = new CPacketItem(name, type, size, initObj, null); } } item.IsSwap = isSwap; items.Add(item); } return(items); }
public void LoadXml(XmlDocument xDoc, XmlNode rootNode, bool refLoad = false) { if (rootNode == null) { return; } XmlControlHandler.GetDefaultControlAttributes(rootNode, xDoc, this, refLoad, Args, GetComponentValue); XmlNode xNode = XmlGetter.Child(rootNode, "TableInfo/BaseRowHeight"); if (xNode != null) { this.BaseRowHeight = int.Parse(xNode.InnerText); } #region getTableColumn XmlNodeList xNodeList = XmlGetter.Children(rootNode, "Columns/Column"); for (int i = 0; i < xNodeList.Count; i++) { XmlNode colNode = xNodeList[i]; if (colNode.NodeType == XmlNodeType.Comment) { continue; } int wid = int.Parse(XmlGetter.Attribute(colNode, "Width")); String name = XmlGetter.Attribute(colNode, "Name"); ItemTypes itemType = (ItemTypes)(ItemTypesText.ToList().IndexOf(XmlGetter.Attribute(colNode, "ItemType"))); XmlNodeList colItems = colNode.ChildNodes; Actions onClickAction = Actions.Auto; Actions onDoubleClickAction = Actions.Auto; Actions onRightClickAction = Actions.Auto; XmlNode properties = null; for (int ci = 0; ci < colItems.Count; ci++) { if (colItems[ci].NodeType == XmlNodeType.Comment) { continue; } if (colItems[ci].Name.Equals("Actions")) { XmlNodeList xActions = colItems[ci].ChildNodes; for (int ai = 0; ai < xActions.Count; ai++) { if (xActions[ai].NodeType == XmlNodeType.Comment) { continue; } switch (xActions[ai].Name) { case "OnClick": onClickAction = (Actions)(ActionsText.ToList().IndexOf(xActions[ai].InnerText)); break; case "OnDoubleClick": onDoubleClickAction = (Actions)(ActionsText.ToList().IndexOf(xActions[ai].InnerText)); break; case "OnRightClick": onRightClickAction = (Actions)(ActionsText.ToList().IndexOf(xActions[ai].InnerText)); break; } } } else { properties = colItems[ci]; } } MakeAColumn(wid, itemType, name, properties, onClickAction, onDoubleClickAction, onRightClickAction); } #endregion #region getRows XmlNode xRows = XmlGetter.Child(rootNode, "Rows"); if (xRows != null && xRows.ChildNodes.Count > 0) { _rows = new XmlScenarioRows(this); Rows.LoadXml(xDoc, xRows); } else { _rows = new XmlScenarioRows(this, xDoc, rootNode); } //xNodeList = XmlGetter.Children(rootNode,"Rows/Row"); #endregion }
public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false) { if (rootNode == null) { return; } XmlControlHandler.GetDefaultControlAttributes(rootNode, xDoc, this); String ns = XmlGetter.Attribute(rootNode, "NameSpace"); if (ns.Length > 0) { if (_namespace != null && _namespace.Length > 0) { _namespace += GlobalVars.Seperator + ns; } else { _namespace = ns; } } XmlNode xInfo = XmlGetter.Child(rootNode, "TabControlInfo"); // rootNode.SelectSingleNode("TabControlInfo"); XmlNode xTabImages = XmlGetter.Child(rootNode, "TabImages"); //xInfo.SelectSingleNode("TabImages"); if (xTabImages != null) { XmlImageList xImgList = new XmlImageList("TabImages"); xImgList.LoadXml(xDoc, xTabImages); this.ImageList = xImgList; } XmlNodeList xTabs = XmlGetter.Children(rootNode, "Tabs/Tab"); for (int i = 0; i < xTabs.Count; i++) { XmlNode xTab = xTabs[i]; //if (xTab.NodeType != XmlNodeType.Element) continue; //주석을 거른다. if (xTab.Name.Equals("Tab") == false) { continue; //오직 자식으로는 Component만을 가진다. } XmlTab tab = new XmlTab(_idList, _namespace); tab.LoadXml(xDoc, xTab); this.TabPages.Add(tab); //_parent.Controls.Add(tab); Dictionary <String, IXmlComponent> idList = tab._idList; /* * for (int ids = 0; ids < idList.Count; ids++) * { * string name = idList.Keys.ElementAt(ids); * if (_namespace.Length > 0) name = _namespace + "." + name; //namespace가 있으면 붙여서 namepace.name 형식으로 다시 naming.. * Controls.Add(name, idList.Values.ElementAt(ids)); * } */ } }