We help IT Professionals succeed at work.

Can you include many child classes in an XmlInclude attribute?

wooderz
wooderz asked
on
967 Views
Last Modified: 2013-12-16
Hi experts!

I am just wondering if the XmlInclude for Serialization can be done using an Interface or similar, see code snippet for example. Just for housekeeping I would like to have all those XmlInclude statements combined into one.
[XmlInclude(typeof(APIBase))]
    [XmlInclude(typeof(SkillList))]
    [XmlInclude(typeof(SkillTypesList))]
    [XmlInclude(typeof(SectorList))]
    [XmlInclude(typeof(WebsiteProperties))]
    [XmlInclude(typeof(CountryList))]
    [XmlInclude(typeof(LanguageList))]
    [XmlInclude(typeof(LexiconBase))]
    [XmlInclude(typeof(LexiconData))]

Open in new window

Comment
Watch Question

Jaime OlivaresSoftware Architect
CERTIFIED EXPERT
Top Expert 2008

Commented:
Yes, you can use several XmlInclude attributes.
You can combine all them as:

[XmlInclude(typeof(APIBase)), XmlInclude(typeof(SkillList)), XmlInclude(typeof(SkillTypesList)), XmlInclude(typeof(SectorList)), XmlInclude(typeof(WebsiteProperties)), XmlInclude(typeof(CountryList)), XmlInclude(typeof(LanguageList)), XmlInclude(typeof(LexiconBase)), XmlInclude(typeof(LexiconData))]

Author

Commented:
Thats really the same thing isn't it? I was hoping I could derive them all from a base class and just do one [XmlInclude(typeof(BaseClass))]
Software Architect
CERTIFIED EXPERT
Top Expert 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.