public ChangeDescription(XElement ChangeElement) { PrimaryKeys = new Dictionary<string, string>(); ChangeValues = new List<Change>(); Comments = new List<string>(); User = ChangeElement.Element("User").Value; Project = ChangeElement.Element("Project").Value; //Could give problems with format DateTime d; if (DateTime.TryParse(ChangeElement.Element("Date").Value, out d)) Date = d; Table = (JupiterTables)Enum.Parse(typeof(JupiterTables), ChangeElement.Element("Table").Value); Action = (TableAction) Enum.Parse(typeof(TableAction), ChangeElement.Element("Action").Value); foreach (var ele in ChangeElement.Element("PrimaryKeys").Elements()) { PrimaryKeys.Add(ele.Element("Key").Value, ele.Element("Value").Value); } foreach (var ele in ChangeElement.Element("ChangedValues").Elements()) { Change c = new Change(ele.Element("Column").Value, ele.Element("NewValue").Value, ele.Element("OldValue").Value); this.ChangeValues.Add(c); } foreach (var ele in ChangeElement.Element("Comments").Elements()) { Comments.Add(ele.Value); } }
public void ToXMLTest() { Change target = new Change(); // TODO: Initialize to an appropriate value target.ColumnName = "BOREHOLE"; target.Action = TableAction.EditValue; target.Comments.Add("No comments"); target.Date = DateTime.Now; target.NewValue = "654000"; target.OldValue = "0"; target.PrimaryKeys.Add(new HydroNumerics.Core.Tuple<string, string>("BOREHOLENO", "193. 127")); target.Project = "NOVANA"; target.User = "******"; var k = target.ToXML(); }