I have a Ref class
public class Ref<T>
{
private Func<T> getter;
private Action<T> setter;
/// <summary>
/// For XML Serialization
/// </summary>
private Ref() { }
public Ref(Func<T> getter, Action<T> setter)
{
this.getter = getter;
this.setter = setter;
}
public Func<T> Getter
{
get { return getter; }
set { getter = value; }
}
public Action<T> Setter
{
get { return setter; }
set { setter = value; }
}
[XmlIgnore]
public T Value
{
get { return getter(); }
set { setter(value); }
}
}
that contains both Func and Action delegates.
If another class has a Ref<float> as one of its properties, how can I correctly serialize and deserialize the Ref<float> class?
I've been playing around with
Type funcType = typeof(Func<>).MakeGenericType(new Type[] { typeof(Ref<float>) });
but I haven't got any closer. Can anyone please help me out here?