[Quantproject-developers] QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting Account
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2008-02-06 20:37:26
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26359/a1_Financial/a2_Accounting/h5_Reporting Modified Files: AccountReport.cs Log Message: Added code for deserialization. Index: AccountReport.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/AccountReport.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** AccountReport.cs 28 Jan 2008 21:30:58 -0000 1.20 --- AccountReport.cs 6 Feb 2008 20:37:19 -0000 1.21 *************** *** 26,30 **** --- 26,32 ---- using System.Collections; using System.Reflection; + using System.Runtime.Serialization; using System.Runtime.InteropServices; + using QuantProject.ADT; using QuantProject.ADT.Histories; *************** *** 41,45 **** /// </summary> [Serializable] ! public class AccountReport { private Account account; --- 43,47 ---- /// </summary> [Serializable] ! public class AccountReport : ISerializable { private Account account; *************** *** 57,60 **** --- 59,63 ---- private EquityLine equityLine; private Tables.Summary summary; + private Tables.StatisticsSummary statisticsSummary; public string Name *************** *** 118,121 **** --- 121,128 ---- get { return summary; } } + public Tables.StatisticsSummary StatisticsSummary + { + get { return this.statisticsSummary; } + } public DateTime StartDateTime { *************** *** 300,307 **** --- 307,362 ---- //this.summary = getSummary( reportName ); this.summary = new Tables.Summary( this , historicalQuoteProvider ); + this.statisticsSummary = new Tables.StatisticsSummary( this, historicalQuoteProvider ); return this; } #endregion + #region Serialization + + /// <summary> + /// This constructor allows custom deserialization (see the ISerializable + /// interface documentation) + /// </summary> + /// <param name="info"></param> + /// <param name="context"></param> + protected AccountReport( SerializationInfo info , StreamingContext context ) : + base( ) + { + // get the set of serializable members for this class and its base classes + Type thisType = this.GetType(); + MemberInfo[] mi = FormatterServices.GetSerializableMembers( + thisType , context); + + // deserialize the fields from the info object + for (Int32 i = 0 ; i < mi.Length; i++) + { + FieldInfo fieldInfo = (FieldInfo) mi[i]; + // set the field to the deserialized value + try + { + fieldInfo.SetValue( this , + info.GetValue( fieldInfo.Name, fieldInfo.FieldType ) ); + } + catch(Exception ex) + {ex = ex;} + } + } + + void ISerializable.GetObjectData( + SerializationInfo info, StreamingContext context) + { + // get the set of serializable members for this class and base classes + Type thisType = this.GetType(); + MemberInfo[] mi = + FormatterServices.GetSerializableMembers( thisType , context); + + // serialize the fields to the info object + for (Int32 i = 0 ; i < mi.Length; i++) + { + info.AddValue(mi[i].Name, ((FieldInfo) mi[i]).GetValue(this)); + } + } + #endregion + public AccountReport Create( string reportName , long numDaysForInterval , EndOfDayDateTime endDateTime ) |