> Note the subject line -- it's protobuf-net.  :)

I see "Class hierarchy serialization" using google-groups.
(ahhh - if you expand "More options" you see the full "[protobuf-net]
Class hierarchy serialization" - interesting!)

OK - to expand:

protobuf-net supports class hierarchies, which is does by representing
subtypes as nested messages (to make it wire compatible), with a bit
of magic thrown in. What it *doesn't* currently support is the open
generic type (GetAll<T>) in the middle of the stack. This is in part
because you need to declare the metadata that it uses to identify
subtypes in the type defintion.

Without the open type, then yes - it is fine:

    [ProtoContract, ProtoInclude(1, typeof(CarMessage))]
    class AbstractMessage {...}

    [ProtoContract]
    class CarMessage : AbstractMessage {...}

Now, regardless of whether you use CarMessage or AbstractMessage when
using Serializer, it will identify the correct type. So if you
serialize an AbstractMessage you will get back an AbstractMessage; if
you serialize CarMessage (as either an AbstractMessage or a
CarMessage) you will always get back a CarMessage (regardless of
whether you ask for an AbstractMessage or a CarMessage).

If there is a good use-case for supporting open generic types, then
that approach *might* fit into the work I'm currently doing that lets
you specify the model separately to the main class definitions. It
wasn't on my plan (and it would have to wait a little bit until I've
completed the current refactor), but it could *potentially* work -
*if* there is a good scenario for it...

Marc Gravell
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to