[英]Serialize read-only collection without implementing IXmlSerializable
I have a class : 我有一堂课:
[Serializable]
public class Profile
{
[XmlAttribute]
private string[] permissions;
public string[] Permissions
{
get { return permissions; }
set { permissions = value; }
}
}
I want to serialize it in XML with XmlSerializer and I also have to be compliant with FxCop. 我想使用XmlSerializer以XML序列化它,并且我还必须与FxCop兼容。 The problem is that FxCop only wants to expose read-only collection for properties, but of course a ReadOnlyCollection is not serializable.
问题是FxCop只希望公开属性的只读集合,但是ReadOnlyCollection当然不能序列化。 I do not want to implement IXmlSerializable because it's too painful.
我不想实现IXmlSerializable,因为它太痛苦了。 Is there any other solution ?
还有其他解决方案吗?
Options: 选项:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.