c# - Multiple XmlElement attributes on same property/class/ -


I am putting many legacy web services and the current web service at the end of the same benchmark.

But I have to keep old web services in sync with the old interface.

So my question:

Is there any way, I can set many features, for example, a property?

Like this:

  [XmlElement ("AvailableFrom", ... what do I need ...)] [XmlElement ("Available", ... I What is needed ...)] Public Date Time Available {get; Set;}  

A solution will create additional properties, but I really do not like the code bloat.

  Personal DateTime _availableFrom; [XmlElement ("Available Forms")] Public Date Time Available {from {Return _availableFrom; } Set {_availableFrom = value; }} [XmlElement ("Available")] Public Date Time Available {get_availableFrom; } Set {_availableFrom = value; }}  

I think there is no easy way for you.

The serialization will fail because there can be two different values ​​for one property.

1) Create XSLT to convert existing XML into old format and change back. In XSLT you are able to handle different values ​​in the best possible way.

or

2) Do not use the serialization properties. Write your own method for this and handle different values ​​there.

or

3) Use your class as a base and create two child classes. Fill two child classes with characteristics for overrides and serialization.


Comments