On 2011-10-21 17:19, Steven Schveighoffer wrote:
On Fri, 21 Oct 2011 10:54:47 -0400, Jacob Carlborg <d...@me.com> wrote:

On 2011-10-21 16:17, Steven Schveighoffer wrote:

This can still be done. If you have the compile-time type you can always
forcefully generate the run time info (I would expect such a feature
when RTTI is fully developed).

The thing is that you may not have access to the compile-time type,
i.e. :

class Base {}
class Sub : Base {}

Base sub = new Sub;

Now the compile-time information specific for Sub is gone when
accessing "sub".

I have this problem with my serialization library. To workaround this
the user have to register the compile-time type with the serializer to
be able to (de)serialize via base class references.

Well, .NET requires you to put an attribute on a class to allow it to be
serializable. And that doesn't seem to get in the way of .NET code that
uses serialization.

-Steve

If I can make it work without specifying an attribute on a class why shouldn't I. One thing less to think about. It's just in this special case the type needs to registered with the serializer.

--
/Jacob Carlborg

Reply via email to