Update of /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv809/Reporting/WindowsForm
Modified Files:
ReportTabControl.cs
Log Message:
Implemented the ISerializable interface, for allowing custom deserialization
Index: ReportTabControl.cs
===================================================================
RCS file: /cvsroot/quantproject/QuantProject/b5_Presentation/Reporting/WindowsForm/ReportTabControl.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ReportTabControl.cs 31 May 2006 14:24:58 -0000 1.4
--- ReportTabControl.cs 6 Feb 2008 23:16:39 -0000 1.5
***************
*** 21,24 ****
--- 21,26 ----
*/
using System;
+ using System.Runtime.Serialization;
+ using System.Reflection;
using System.Windows.Forms;
***************
*** 31,35 ****
/// TabControl for the report form
/// </summary>
! public class ReportTabControl : TabControl
{
private AccountReport accountReport;
--- 33,38 ----
/// TabControl for the report form
/// </summary>
! [Serializable]
! public class ReportTabControl : TabControl, ISerializable
{
private AccountReport accountReport;
***************
*** 39,42 ****
--- 42,46 ----
private ReportGridTabPage equity;
private ReportGridTabPage transactions;
+ private StatisticsSummaryTabPage statisticsSummary;
public ReportGrid TransactionGrid
***************
*** 48,51 ****
--- 52,105 ----
get { return this.equityChart.EquityChart; }
}
+
+ /// <summary>
+ /// This constructor allows custom deserialization (see the ISerializable
+ /// interface documentation)
+ /// </summary>
+ /// <param name="info"></param>
+ /// <param name="context"></param>
+ protected ReportTabControl( 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;}
+ }
+ }
+
+ /// <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));
+ }
+ }
/// <summary>
***************
*** 74,77 ****
--- 128,133 ----
"Transactions" , this.accountReport.TransactionTable );
this.Controls.Add( this.transactions );
+ this.statisticsSummary = new StatisticsSummaryTabPage( this.accountReport );
+ this.Controls.Add( this.statisticsSummary );
}
}
|