The code from the example abovee is
[XmlIgnore()]
[Display(Name[COLOR=#ffffff] [/COLOR]=[COLOR=#ffffff] [/COLOR][COLOR=#800000]"BorderBrush"[/COLOR],[COLOR=#ffffff] [/COLOR]GroupName[COLOR=#ffffff] [/COLOR]=[COLOR=#ffffff] [/COLOR][COLOR=#800000]"NinjaScriptParameters"[/COLOR],[COLOR=#ffffff] [/COLOR]Order[COLOR=#ffffff] [/COLOR]=[COLOR=#ffffff] [/COLOR][COLOR=#ff6600]0[/COLOR])]
[COLOR=#0000ff]public [/COLOR]Brush[COLOR=#ffffff] [/COLOR]BorderBrush
{[COLOR=#ffffff] [/COLOR]get;[COLOR=#ffffff] [/COLOR]set;[COLOR=#ffffff] [/COLOR]}
[Browsable([COLOR=#0000ff]false[/COLOR])]
[COLOR=#0000ff]public[/COLOR][COLOR=#ffffff] [/COLOR][COLOR=#0000ff]string[/COLOR][COLOR=#ffffff] [/COLOR]BorderBrushSerialize
{
get[COLOR=#ffffff] [/COLOR]{[COLOR=#ffffff] [/COLOR][COLOR=#0000ff]return[/COLOR][COLOR=#ffffff] [/COLOR]Serialize.BrushToString(BorderBrush);[COLOR=#ffffff] [/COLOR]}
[COLOR=#ffffff] [/COLOR]set[COLOR=#ffffff] [/COLOR]{[COLOR=#ffffff] [/COLOR]BorderBrush[COLOR=#ffffff] [/COLOR]=[COLOR=#ffffff] [/COLOR]Serialize.StringToBrush(value);[COLOR=#ffffff] [/COLOR]}
}
This becomes further complicated if the object in question requires custom code in the Clone() handler. Consider the following.
class Foo
{
int someCustomData;
double moreCustomData;
// Additional members, code to manage object foo and handle properties.
}
class MyIndicator : IndicatorBase
{
Foo someCustomObject;
[Browsable(false)]
public string FooSerialize
{
get { return someCustomData != null ? someCustomObject.SerializeToString() : string.Empty; }
set
{ someCustomObject = Foo.SerializeFromString(value); }
}
public override object Clone()
{
// save the original foo object
Foo originalCustomData = someCustomData;
// if we don't set someCustomData to null it will be serialized and deserialized when FooSeralize is copied by the clone method
someCustomData = null;
// If we don't use the clone method provided by the base, then we are responsible for copying everything? Its not clear how best
// to go about copying all the various things needed to properly copy an Indicator
var result = base.Clone();
// Restore the originalCustomData back. // If an exception is thrown by base.Clone() this will be lost. Need to figure out a way to
// mitigate this.
someCustomData = originalCustomData;
// now do our custom cloning
if(result != null)
{
result.someCustomData = someCustomData.SomeCustomCloneMethod();
}
}
}
How does one prevent a serialization property from being copied by the Clone() method?

Comment