![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Readonly collection support in DataContractSerializer? Just getting to grips with the new (to me) DataContractSerializer through WCF and my class is failing to serialize because a [DataMember] doesn't have a setter. But there's a good reason for this - the property is a readonly collection, you know... private List<SomeType> _things = new List<SomeType>(); [DataMember] public List<SomeType> Things { get { return _things; } } The old XmlSerializer used to understand this and play nicely but the DataContract serializer doesn't seem to want to. Any ideas? Am I missing an attribute somewhere? |
| | #2 (permalink) |
| Guest | Re: Readonly collection support in DataContractSerializer? You do can continue to use XmlSerializer if it's good for you http://msdn.microsoft.com/msdnmag/is...efault.aspx#S4 Arkady "MrAnon" <josh.twist@gmail.com> wrote in message news:1162992886.697261.198840@i42g2000cwa.googlegroups.com... > Just getting to grips with the new (to me) DataContractSerializer > through WCF and my class is failing to serialize because a [DataMember] > doesn't have a setter. But there's a good reason for this - the > property is a readonly collection, you know... > > private List<SomeType> _things = new List<SomeType>(); > > [DataMember] > public List<SomeType> Things > { > get { return _things; } > } > > The old XmlSerializer used to understand this and play nicely but the > DataContract serializer doesn't seem to want to. > > Any ideas? Am I missing an attribute somewhere? > |
| | #4 (permalink) |
| Guest | Re: Readonly collection support in DataContractSerializer? Additionally : you can set empty setter to be it happy ![]() Arkady "MrAnon" <josh.twist@gmail.com> wrote in message news:1163003829.126813.163320@f16g2000cwb.googlegroups.com... > Thanks Arkady, > > I am aware of that option but I'm wondering if it's possible to > configure the DataContract Serializer to be happy with this... > > Anyone? > |
| | #5 (permalink) |
| Guest | Re: Readonly collection support in DataContractSerializer? But the serializer will add things to the collection that we ignored... so my collection will always be emtpy ![]() Arkady Frenkel wrote: > Additionally : you can set empty setter to be it happy ![]() > Arkady > > "MrAnon" <josh.twist@gmail.com> wrote in message > news:1163003829.126813.163320@f16g2000cwb.googlegroups.com... > > Thanks Arkady, > > > > I am aware of that option but I'm wondering if it's possible to > > configure the DataContract Serializer to be happy with this... > > > > Anyone? > > |
| | #6 (permalink) |
| Guest | Re: Readonly collection support in DataContractSerializer? BTW , you can ask additionally if that documented somewhere on http://forums.microsoft.com/MSDN/Sho...D=118&SiteID=1 Arkady "MrAnon" <josh.twist@gmail.com> wrote in message news:1163677111.476397.14850@k70g2000cwa.googlegroups.com... > But the serializer will add things to the collection that we ignored... > so my collection will always be emtpy ![]() > > > Arkady Frenkel wrote: > >> Additionally : you can set empty setter to be it happy ![]() >> Arkady >> >> "MrAnon" <josh.twist@gmail.com> wrote in message >> news:1163003829.126813.163320@f16g2000cwb.googlegroups.com... >> > Thanks Arkady, >> > >> > I am aware of that option but I'm wondering if it's possible to >> > configure the DataContract Serializer to be happy with this... >> > >> > Anyone? >> > > |
| | #7 (permalink) |
| Guest | RE: Readonly collection support in DataContractSerializer? MrAnon, The behavior for DataContractSerializer mentioned below is currently by design. Using an empty setter, as mentioned later in the thread will result in data lost during deserialization. Thanks, Sara "MrAnon" wrote: > Just getting to grips with the new (to me) DataContractSerializer > through WCF and my class is failing to serialize because a [DataMember] > doesn't have a setter. But there's a good reason for this - the > property is a readonly collection, you know... > > private List<SomeType> _things = new List<SomeType>(); > > [DataMember] > public List<SomeType> Things > { > get { return _things; } > } > > The old XmlSerializer used to understand this and play nicely but the > DataContract serializer doesn't seem to want to. > > Any ideas? Am I missing an attribute somewhere? > > |
| |
| |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| RE: ReadOnly | Ken Zhao [MSFT] | Vista networking & sharing | 0 | 11-04-2007 09:08 PM |
| setting a variable as readonly | klumsy@xtra.co.nz | PowerShell | 4 | 10-27-2006 12:14 AM |