private static void GetColumns(GXDLT645TableTemplate table, XmlNode parentNode) { foreach (XmlNode childNode in parentNode.ChildNodes) { if (childNode.NodeType == XmlNodeType.Element) { GXDLT645Data item = new GXDLT645Data(childNode.Attributes["Name"].Value); if (childNode.Attributes["Type"] != null) { item.Type = (DataType)Enum.Parse(typeof(DataType), childNode.Attributes["Type"].Value); } table.Columns.Add(item); } } }
static internal Dictionary<ulong, object> ReadDataID() { string filePath = Path.Combine(Path.GetDirectoryName(typeof(GXDLT645Property).Assembly.Location), "DLTProperties.xml"); XmlDataDocument myXmlDocument = new XmlDataDocument(); if (!File.Exists(filePath)) { myXmlDocument.LoadXml(Gurux.DLT645.AddIn.Properties.Resources.DLTProperties); try { using (XmlTextWriter writer = new XmlTextWriter(filePath, Encoding.Default)) { myXmlDocument.Save(writer); writer.Close(); } } catch (System.IO.IOException) { //This is probably due to insufficient file access rights. } } else { myXmlDocument.Load(filePath); } Dictionary<ulong, object> items = new Dictionary<ulong, object>(); foreach (XmlNode parentNode in myXmlDocument.DocumentElement.ChildNodes) { if (parentNode.Name == "Properties") { GetProperties(items, parentNode); } else if (parentNode.Name == "Tables") { foreach (XmlNode table in parentNode.ChildNodes) { GXDLT645TableTemplate item = new GXDLT645TableTemplate(table.Attributes["Name"].Value); items.Add(Convert.ToUInt64(table.Attributes["ID"].Value, 16), item); foreach (XmlNode prop in parentNode.ChildNodes) { GetColumns(item, prop); } } } } return items; }