I have a class with a lot of value members and a few very big reference members, like this:
[Serializable]
public class Data
{
string Name {get;set;}
int AnInt {get;set;}
int AnotherInt {get;set;}
...
List<Object> HugeList;
}
I want to marshal instances of this class by value, except that I only want to pass the HugeList member when specifically requested by a client.
If I mark HugeList [NonSerialized] and then add a GetHugeList() method it won't work because the Get method will look at the local copy of the class instance, where HugeList will be null because it's not Serialized.
Is there any trick to do all of the following:
- Keep the large members in the class
- Marshal instances of the class by value, except for the large members
- Allow a remote client to explicitly request a serialized copy of the large members