Dear sirs,
I am using custom wrappers to primitive types in my classes, so I can
have some flags when working with the database ("undefined" and "null")
.
So instead of:
[Serializable]
public class User
{
private int _id;
private string _name;
public int Id
{ get {return this._id;} }
public string Name
{ get {return this._name;} }
}
I have:
[Serializable]
public class User
{
private MyIntWrapper _id;
private MyStringWrapper _name;
public MyIntWrapper Id
{ get {return this._id;} }
public MyStringWrapper Name
{ get {return this._name;} }
}
In the wrapper objects I have a ".Value" attribute that sets/returns
the primitive type. If the wrapper is flagged as null or undefined it
THROWS AN EXCEPTION. That is a by-design behavior.
The problem is: even if I mark MyIntWrapper, MyStringWrapper and User
classes with [Serializable] attribute, I get an Exception when trying
to serialize an instance of User, because sometimes one of its
properties is undefined or null and therefore throws nd exception when
being accessed.
How can I solve this? Do I need a custom serialization and
de-serialization?
TIA,
Leo D'Ippolito
CG - 18 Nov 2005 01:52 GMT
You would need to write customer serialization to handle this situation.
> Dear sirs,
>
[quoted text clipped - 48 lines]
>
> Leo D'Ippolito