IXmlSerializable is still for internal use in vs 2005
béta, but this time MS gives samples!
I don't understand this anyway, why not fully document
this interface? It's just an interface after all and
runtime serialization has a full support for
customization already.
thank you
Amethyste
[color=blue]
>-----Original Message-----
>Hi:
>
>Till .NET 1.1, IXmlSerializable was mostly intended for [/color]
internal (MS) use.[color=blue]
>With 2.0, IXmlSerializable is receiving more publicity [/color]
and programmers will[color=blue]
>be encouraged to use it.
>For info about how to implement IXmlSerializable in 1.1:
>
http://dotnetified.com/PermaLink.asp...E86B447E-AA95-[/color]
49B6-909F-CDA36ACF481F[color=blue]
>
>Mujtaba.
>
>"amethyste" <anonymous@discussions.microsoft.com> wrote [/color]
in message[color=blue]
>news:038601c4ed1b$db33ee10$a601280a@phx.gbl...[color=green]
>> thank you,
>>
>> I suspected something like this.
>> I'm in the case where IXmlSerializable is the solution.
>>
>> But IXmlSerializable is not officially documented. This
>> wories me a little bit.
>>
>>[color=darkred]
>> >-----Original Message-----
>> >
>> >amethyste,
>> >
>> >are you trying to dynamically set the element name [/color][/color][/color]
based[color=blue][color=green]
>> on values in[color=darkred]
>> >your object, i.e. if the propertyName is foo and the[/color]
>> label is set to[color=darkred]
>> >range, then the serialized XML is
>> >
>> ><foo range="..." />?
>> >
>> >First, changing the element name is only possible if [/color][/color][/color]
you[color=blue][color=green]
>> have a fixed[color=darkred]
>> >set of element names, but not if propertyName can hold[/color]
>> arbitrary[color=darkred]
>> >strings. XML serialization is intended to be used with
>> >strongly-structured XML data. Therefore it works best [/color][/color][/color]
if[color=blue][color=green]
>> you can express[color=darkred]
>> >the XML format as an XML Schema. You can change the[/color]
>> element names either[color=darkred]
>> >based on the type of the serialized object:
>> >
>> >[XmlElement( "foo", typeof(fooType))]
>> >[XmlElement( "bar", typeof(barType))]
>> >public foobarType propertyName;
>> >
>> >or by using the choice construct [0].
>> >
>> >Second, changing the attribute name dynamically only[/color]
>> works based on the[color=darkred]
>> >type of the serialized type via attaching multiple[/color]
>> attributes. There is[color=darkred]
>> >no equivalent to the choice construct for attributes.
>> >
>> >If you need to be able to by more dynamic than that [/color][/color][/color]
you[color=blue][color=green]
>> must implement[color=darkred]
>> >IXmlSerializable [1].
>> >
>> >HTH,
>> >Christoph Schittko
>> >MVP XML
>> >
http://weblogs.asp.net/cschittko
>> >
>> >
>> >
>> >[0][/color]
>> [/color][/color]
http://www.topxml.com/xmlserializer/...odel_groups.as[color=blue][color=green]
>> p[color=darkred]
>> >[1]
http://msdn2.microsoft.com/library/fhd7bk0a.aspx
>> >
>> >> -----Original Message-----
>> >> From: amethyste[/color]
>> [mailto:anonymous@discussions.microsoft.com][color=darkred]
>> >> Posted At: Tuesday, December 28, 2004 7:16 AM
>> >> Posted To: microsoft.public.dotnet.xml
>> >> Conversation: question about xml serilization
>> >> Subject: question about xml serilization
>> >>
>> >> hello,
>> >>
>> >> This is my sample (simplified):
>> >>
>> >> public class Binom
>> >> {
>> >> [XmlAttribute("range")]
>> >> public string _Value;
>> >>
>> >> [XmlAttribute("name")]
>> >> public string Label;
>> >> }
>> >>
>> >> public class Property
>> >> {
>> >> [XmlAttribute("name")]
>> >> public string propertyName;
>> >>
>> >> public Binom DefaultAttribute;
>> >> }
>> >>
>> >>
>> >> Property serialize as:
>> >>
>> >> <Properties name="foo">
>> >> <DefaultAttribute value="123456789" name="range" />
>> >> </Properties >
>> >>
>> >> Is is possible to get rather:
>> >>
>> >> <foo range="123456789"/>
>> >>
>> >> or eventualy:
>> >>
>> >> <Properties name="foo">
>> >> <DefaultAttribute range="123456789" />
>> >> </Properties >
>> >>
>> >> Just using the default Xml serailization?
>> >>
>> >> Thank you
>> >>
>> >> Happy new years
>> >
>> >.
>> >[/color][/color]
>
>
>.
>[/color]