Hi Bartosz;

At the moment, it only supports the reflection/attribute based approach
(directly comparably to the [KnownType] attribute used in vanilla WCF /
DataContractSerializer). I have some plans and prototype code to rectify
this (runtime models), but it is lots of work, and it isn't anything I can
promise on any fixed timescale I'm afraid.

In order to shim inheritance into the protocol buffers format (without doing
anything /too/ evil) it needs to know a unique tag per subclass. I can't
help thinking that the most pragmatic option here is just to add a few
attributes. Hunting for subclasses on the fly would be messy, and I can't
include the type metadata without breaking completely from the standard
protocol buffers wire format.

Marc Gravell
(protobuf-net)

2009/12/10 Bartosz Pierzchlewicz <bar...@extranet.one.pl>

> Hello,
>
> I have two classes:
>
>        [DataContract]
>        public class TestClass: Base<TestClass>
>        {
>                [DataMember(Order = 1)]
>                public string Str { get; set; }
>        }
>
>        [DataContract]
>        [ProtoInclude(1,typeof(TestClass))]
>        public class Base<T>
>        {
>                [DataMember]
>                public T ReturnType { get; set; }
>        }
>
> I know, that I must use ProtoInclude attribute to allow serialization.
>
> Problem is, that I have about 100 classes that inherit from Base
> class, and I should write 100 attributes.
> Is any possibility to add this information not using Attribute on
> class but programmatically?
>
> In DataContractSerializerOperationBehavior when you override method
> CreateSerializer you may write code to add your own list of known
> types.
>
> But.. ProtoInclude has not only information about type but also tag.
>
>
> can anyone help?
>
> Bartosz Pierzchlewicz
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>
>


-- 
Regards,

Marc

--

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@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