The object[] mList holds whatever objects that the child collection wants it to. This is supposed to be a dummy wrapper class for the rest of the more specified collections of objects.
[ProtoInclude(98, typeof(Object1CollectionProto))]
[ProtoInclude(99, typeof(Object2CollectionProto))]
[ProtoInclude(100, typeof(Object3CollectionProto))]
public class ObjectCollectionProto
{
protected ObjectType mCollectionType;
protected object[] mList;
public ObjectCollectionProto(){}
[ProtoMember(1), DefaultValue(ObjectType.Base)]
public ObjectType CollectionType //enumeration for type
{
get { return mCollectionType; }
set { mCollectionType = value;}
}
[ProtoMember(2)]
public object[] List
{
get { return mList; }
set { mList = value;}
}
}
Then we have an example child class of the above dummy wrapper that is supposed to inherit the object[] of it's desired type.
[ProtoContract]
public class Object1CollectionProto : ObjectCollectionProto
{
public Object1CollectionProto()
{
}
}
How do I go about specifying the class hierarchy so that Object1CollectionProto inherits a the object[] mList as a list of Object1's that can be serialized? Object1's can be serialized in my case already. Just not the collection version of them.
How to serialize arrays? This is a good way to solve the problem, just remake the framework to fit this way of serializing arrays.
Also with some careful thinking I made a way of serializing that array correctly. In my case I NEVER actually serialize the PARENT class, but rather I only serialize the CHILDREN.
I removed the ProtoMember attribute from the parent class array and set the array in the children, with a specific type into the CHILDREN classes.