开发者

.NET: Is There an Interface for Implemented by all XML Serialized objects?

开发者 https://www.devze.com 2022-12-09 19:04 出处:网络
I 开发者_高级运维want a method to return an XML Serialized Typed object. Is there an interface I can use to enforce this requirement?IXmlSerializable will allow you to customize XML serialization/dese

I 开发者_高级运维want a method to return an XML Serialized Typed object. Is there an interface I can use to enforce this requirement?


IXmlSerializable will allow you to customize XML serialization/deserialization. However, it still uses XmlSerializer to serialize data to or from XML.


Implement ISerializable


is this what you mean?

http://msdn.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx


There is no interface that means "this object can be XML Serialized". IXmlSerializable means that the caller is stating that it implements XML Serialization on its own, and that the XML Serializer does not need to generate code to serialize it.

The following type is XML Serializable, but does not implement IXmlSerializable:

public class SerializeMe
{
    public string SomeProperty {get; set;}
}

There is no interface that could be used as a return type which could both return an IXmlSerializable instance and the above class.

0

精彩评论

暂无评论...
验证码 换一张
取 消