I've created a custom class WeekTimeRange and added property to the strategy:
public WeekTimeRange[] WeekTimeSchedule. I verified that the property's data properly serializes and deserializes in/out from the strategy template xml file.
I haven't created any custom serialization/deserialization functionality.
Now, when I compile new version of my strategy and enable the existing strategy in the strartegy tab, I get an error in the Output window:
**NT** Error on getting/setting property 'WeekTimeSchedule' for strategy : Object of type '[Commoneo.Order.WeekTimeRange]' cannot be converted to type '[Commoneo.Order.WeekTimeRange]'.
The strategy doesn't start. I found out that this is because of the different versions of the strategy: the preconfigured strategy and the latest that they are referring to. When I, however, open up strategy for parameters editing in the strategy tab and click OK, then there is no such problem: no error and the strategy can start. Note, that the class Commoneo.Order.WeekTimeRange have not been changed in the newer version of the strategy.
I have two questions regarding to this issue:
1. Why is preset in the Strategy tab is still referring the old version of the strategy? The strategy is not running when I recompile it.
2. Is there any way to implement tolerant version serialization for the property with custom class type?
private List<WeekTimeRange> weekTimeSchedule = null;
[Category("Parameters")]
public WeekTimeRange[] WeekTimeSchedule
{
get { return this.weekTimeSchedule != null ? this.weekTimeSchedule.ToArray() : null; }
set
{
if (value == null)
this.weekTimeSchedule = null;
else
this.weekTimeSchedule = new List<WeekTimeRange>(value);
}
}
public class WeekTimeRange
{
public DayOfWeek DayOfWeek { get; set; }
[TypeConverter(typeof(StringToTimeConverter))]
public DateTime Time { get; set; }
public WeekTimeRange()
{
//..
}
public WeekTimeRange(DayOfWeek dayOfWeek, DateTime time)
{
//..
}
public override string ToString()
{
return string.Format(
this.DayOfWeek.ToString() + ", " + this.Time.ToString(StringToTimeConverter.TimeForma t);
}
}

Comment