/// <summary> Deserialization implementation. </summary> public override bool Deserialize(XElement elem, ITypeData t, Action <object> setResult) { if (t.IsA(typeof(TestStepList)) == false) { return(false); } var steps = new TestStepList(); foreach (var subnode in elem.Elements()) { ITestStep result = null; try { if (!Serializer.Deserialize(subnode, x => result = (ITestStep)x)) { Log.Warning(subnode, "Unable to deserialize step."); continue; // skip to next step. } } catch (Exception ex) { Log.Error(ex); continue; } if (result != null) { steps.Add(result); } } setResult(steps); return(true); }
/// <summary> Serialization implementation. </summary> public override bool Serialize(XElement elem, object target, ITypeData expectedType) { if (target is TestStepList) { TestStepList list = (TestStepList)target; for (int i = 0; i < list.Count; i++) { var item = list[i]; XElement newelem = new XElement("TestStep"); Serializer.Serialize(newelem, item); elem.Add(newelem); } return(true); } return(false); }
private void InitializeTestList(string xmlFile) { XmlDocument xml = new XmlDocument(); xml.Load(xmlFile); Node_TestSteps = xml.SelectSingleNode("Root").ChildNodes[0]; Node_TestItems = xml.SelectSingleNode("Root").ChildNodes[1]; foreach (var teststep in Node_TestSteps.ChildNodes) { string n = (teststep as XmlNode).Attributes["Name"].Value; string d = (teststep as XmlNode).Attributes["DisplayName"].Value; TestStepList.Add(new Tuple <string, string>(n, d)); } foreach (var testitem in Node_TestItems.ChildNodes) { string n = (testitem as XmlNode).Attributes["Name"].Value; int v = Convert.ToInt16((testitem as XmlNode).Attributes["Value"].Value); TestItemList.Add(new Tuple <string, int>(n, v)); } }