I'm trying to use ProtoBuf-NET in my project (it's mostly Silverlight 4 project).
I'm having difficulties serializing my Model collections, they all are defined like this:
private List<T> _itemsSet;
public IEnumerable<T> TSet
{
get {return _itemsSet;}
set {_itemsSet = value == null ? new List<T>() : new List<T>(value);}
}
public void AddT(T item)
{
//Do my logic here
_itemsSet.Add(item);
}
Update: First I can't serialize it - No serializer defined for type: System.Collections.Generic.IEnumerable
1[MyType]`. Second I think I will be unable to desirialize it based on manual, and protobuf-net source code analyzes.
- Is there a way to extend protobuf-net to supply delegate to external Add method in ProtoMemeber attribute?
- Why using
ProtoMember(1, OverwriteList=true)
doesn't work? Doesn't it suppose to overwrite collection and shouldn't care aboutAdd<T>()
method? Why it just don't try to set this property to T[] orList<T>
or any set assignable toIEnumerable<T>
? - Is there a way to supply custom reflection mechanism to work with private fields in Silverlight, like: implementing:
public interface IReflectable{ object GetValue(FieldInfo field); void SetValue(FieldInfo field, object value); }
to work with private fields. I have used such approach to work with private fields with Db4o: http://community.versant.com/Forums/tabid/98/aft/10881/Default.aspx - What options I have except creating inherited
MyTypeCollection<T> : Collection<T>
?