[Quantproject-developers] QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2006-06-24 14:46:04
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv19332/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger Modified Files: WFLagLog.cs Log Message: The ISerializable interface is implemented now. I suggest to read the interface implementation, to replicate it for other serializable classes expected to enrich in future releases. Index: WFLagLog.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WFLagDebugger/WFLagLog.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WFLagLog.cs 8 Apr 2006 18:10:21 -0000 1.1 --- WFLagLog.cs 24 Jun 2006 14:46:00 -0000 1.2 *************** *** 22,28 **** using System; using QuantProject.ADT.Histories; - using QuantProject.Business.Financial.Accounting.Transactions; --- 22,29 ---- using System; + using System.Reflection; + using System.Runtime.Serialization; using QuantProject.ADT.Histories; using QuantProject.Business.Financial.Accounting.Transactions; *************** *** 33,37 **** /// </summary> [Serializable] ! public class WFLagLog { private int inSampleDays; --- 34,38 ---- /// </summary> [Serializable] ! public class WFLagLog : ISerializable { private int inSampleDays; *************** *** 56,59 **** --- 57,64 ---- } + public History ChosenPositionsHistory + { + get { return this.chosenPositionsHistory; } + } public WFLagLog( int inSampleDays , string benchmark ) { *************** *** 62,65 **** --- 67,116 ---- this.chosenPositionsHistory = new History(); } + /// <summary> + /// This constructor allows custom deserialization (see the ISerializable + /// interface documentation) + /// </summary> + /// <param name="info"></param> + /// <param name="context"></param> + protected WFLagLog( SerializationInfo info , StreamingContext context ) + { + // 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 + fieldInfo.SetValue( this , + info.GetValue( fieldInfo.Name, fieldInfo.FieldType ) ); + } + + } + #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 + public void Add( WFLagChosenPositions wFLagChosenPositions ) { |