public override void ReadXml(XmlReader reader) { var document = XDocument.Load(reader); foreach (XElement element in document.Root.Element(nameof(Fields)).Elements(nameof(CriField))) { fields.Add( element.Element(nameof(CriField.FieldName)).Value, Type.GetType(element.Element(nameof(CriField.FieldType)).Value) ); } foreach (XElement element in document.Root.Element(nameof(Rows)).Elements(nameof(CriRow))) { CriRow row = NewRow(); foreach (CriRowRecord record in row.Records) { if (record.Field.FieldType == typeof(byte[])) { record.Value = Convert.FromBase64String(element.Element(record.Field.FieldName).Value); } else { record.Value = Convert.ChangeType(element.Element(record.Field.FieldName).Value, record.Field.FieldType); } } rows.Add(row); } }
public CriRow NewRow() { CriRow criRow = new CriRow(this); foreach (CriField criField in fields) { criRow.Records.Add(new CriRowRecord { Field = criField, Value = criField.DefaultValue }); } return(criRow); }