[Quantproject-developers] QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2007-09-05 22:10:21
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18367/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables Modified Files: Summary.cs Log Message: Added summary item AverageNumberOfTransactionsPerDay. Now Summary class implements ISerializable interface, in order to be fully compatible with old serialized version of Summary objects. Index: Summary.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/Tables/Summary.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Summary.cs 8 Jun 2006 18:42:37 -0000 1.19 --- Summary.cs 5 Sep 2007 22:10:16 -0000 1.20 *************** *** 1,4 **** --- 1,7 ---- using System; using System.Data; + using System.Reflection; + using System.Runtime.Serialization; + using QuantProject.ADT; using QuantProject.Business.DataProviders; *************** *** 13,17 **** /// </summary> [Serializable] ! public class Summary : ReportTable { private AccountReport accountReport; --- 16,20 ---- /// </summary> [Serializable] ! public class Summary : ReportTable, ISerializable { private AccountReport accountReport; *************** *** 44,47 **** --- 47,52 ---- private NumberLosingPeriods numberLosingPeriods; private PercentageWinningPeriods percentageWinningPeriods; + private AverageNumberOfTransactionsPerDay averageNumberOfTransactionsPerDay; + public AccountReport AccountReport { *************** *** 163,167 **** get { return this.numberWinningShortTrades; } } ! --- 168,175 ---- get { return this.numberWinningShortTrades; } } ! public AverageNumberOfTransactionsPerDay AverageNumberOfTransactionsPerDay ! { ! get { return this.averageNumberOfTransactionsPerDay; } ! } *************** *** 183,186 **** --- 191,247 ---- this.summary( accountReport ); } + + /// <summary> + /// This constructor allows custom deserialization (see the ISerializable + /// interface documentation) + /// </summary> + /// <param name="info"></param> + /// <param name="context"></param> + protected Summary( SerializationInfo info , StreamingContext context ) : + base( "Summary" ) + { + // 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;} + } + } + + #region GetObjectData + /// <summary> + /// serialize the set of serializable members for this class and base classes + /// </summary> + /// <param name="info"></param> + /// <param name="context"></param> + 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 + #region "getSummary" private void getSummaryTable_setColumns( DataTable equityDataTable ) *************** *** 225,229 **** this.numberWinningShortTrades = new NumberWinningShortTrades( this ); this.totalCommissionAmount = new TotalCommissionAmount( this ); ! // this.DataTable = getSummaryDataTable(); } --- 286,291 ---- this.numberWinningShortTrades = new NumberWinningShortTrades( this ); this.totalCommissionAmount = new TotalCommissionAmount( this ); ! this.averageNumberOfTransactionsPerDay = new AverageNumberOfTransactionsPerDay(this); ! //this.DataTable = getSummaryDataTable(); } |