覆盖"XMLInclude".属性 [英] Overriding the "XMLInclude" attribute

查看:140
本文介绍了覆盖"XMLInclude".属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在研究过程中,我知道如何使用动态类型覆盖xmlarray属性,但没有找到如何覆盖类的"XMLInclude".
有人可以帮忙吗?

During my researches, i''ve known how to override the xmlarray attribute with dynamic types but did not find how to override the "XMLInclude" for classes.
Can anyone help?

推荐答案

[为了回应DaBombNL的评论,我I了部分答案.不过,建议Mehdi提出更清晰的问题;他可以明确提及XmlAttributeOverrides(这是全部吗?)— SA]

对不起,这是无效的问题. 覆盖"的概念仅与虚拟类的方法或属性(更确切地说是属性的获取器或设置器)有关,而与其他任何东西都没有关系.

可以将属性System.Xml.Serialization.XmlIncludeAttribute应用于类,结构,方法或接口,请参见
如果我不敢怀疑您对覆盖概念不太熟悉,我建议您应该搁置所有序列化并立即学习,因为这是OOP的障碍.没有你就不能做任何真正的编程.
我希望这还不错:您可以简单地滥用术语.

在这种情况下,您需要解释您的基本想法(不是如何替代"而是要实现的目标).

—SA
[I scratched part of this answer in response to the comment by DaBombNL. Still, Mehdi is recommended to ask questions more clearly; he could mention XmlAttributeOverrides (is that it all about?) explicitly — SA]

Sorry, this is invalid question. The notion of "override" is only relevant to the virtual class methods or properties (more exactly, getters or setters of a property) and nothing else.

The attribute System.Xml.Serialization.XmlIncludeAttribute can is applied to a class, structure, method or an interface, see http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlincludeattribute.aspx[^].

By the way, the XmlIncludeAttribute class itself is not sealed, so you could create a derived class out of it, but why? The purpose of any attribute is to add some meta-data to the code; it basically plays the same role as type name or inheritance relationship, etc. The presence/absence and properties of the attribute and its properties simply serve as a reference for some code (serialization code in this case); basically, the code detects the presence of some attributes, reads their properties and "decides" how to proceed based on this meta-data.

If I dare to suspect that you''re not well familiar with the override concept, I would suggest you should set aside all your serialization and learn it right away, as this is a hart of OOP; you could not do any real programming without.
I hope, this is not that bad: you could simply misuse the terminology.

In this case, you need to explain your base idea (not how to "override" but what you want to achieve).

—SA


这篇关于覆盖"XMLInclude".属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆