public void Serialize() { var cl = new TstClient(); var a = cl.GetRoot<Root>().AItems.First(); a.Value = 10; var report = new XReport(a.Uid, a.GetChanges(), (int) a.Kind, EState.SINGLE); var ser = new DataContractSerializer(typeof (XReport) //, new Type[] { typeof(XReportItem<Int32>)} ); var sb = new StringBuilder(); using (var writer = XmlWriter.Create(sb, new XmlWriterSettings {OmitXmlDeclaration = true})) { ser.WriteObject(writer, report); } var xml = sb.ToString(); var resultSerializer = new DataContractSerializer(typeof (XReport) //, new Type[] { typeof(XReportItem<Int32>) } ); XReport deserializedReport; var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); { deserializedReport = (XReport) resultSerializer.ReadObject(stream); } var reportHC = report; var deserializedHC = deserializedReport.GetHashCode(); Assert.AreEqual(report.Uid, deserializedReport.Uid); }
public void UpdateAccordingNewValues(Dictionary<int, IServerXValue> _xValues, XReport _reverseReport) { var items = new List<AbstractXReportItem>(); foreach (var reportItem in Items) { var newItem = reportItem.UpdateAccordingNewValue(_xValues[reportItem.FieldId], _reverseReport.Items.SingleOrDefault(_item => _item.FieldId == reportItem.FieldId)); if (newItem != null) { items.Add(newItem); } } Items = items; }
public void UpdateAccordingNewValues(Dictionary <int, IServerXValue> _xValues, XReport _reverseReport) { var items = new List <AbstractXReportItem>(); foreach (var reportItem in Items) { var newItem = reportItem.UpdateAccordingNewValue(_xValues[reportItem.FieldId], _reverseReport.Items.SingleOrDefault(_item => _item.FieldId == reportItem.FieldId)); if (newItem != null) { items.Add(newItem); } } Items = items; }