我正在使用Xml序列化来保存磁盘上的某些对象。XmlInclude属性和派生类
类结构如下:
XmlInclude(typeof(BranchExplorerViewInfo))
public class ViewInfo
{
...
}
public class BranchExplorerViewInfo : ViewInfo
{
...
}
public class CustomBranchExplorerViewInfo: BranchExplorerViewInfo
{
...
}
然后,我需要以下行为:
BranchExplorerViewInfo view = new BranchExplorerViewInfo();
view.GetType().IsSerializable; //I need this to be TRUE
CustomBranchExplorerViewInfo customView = new CustomBranchExplorerViewInfo();
customView.GetType().IsSerializable; //I need this to be FALSE
所以,我想BranchExplorerViewInfo
可序列化,但CustomBranchExplorerViewInfo
是不可序列。有排除类型/类的属性吗?
在此先感谢。
你的意思是你在序列化一个包含混合类型对象列表的属性? – 2011-03-30 14:29:24
@Ondrej:我正在序列化整个类,所以我需要排除CustomBranchExplorerViewInfo类型。 – 2011-03-30 14:34:47
我想你错过了我的观点:我问你使用这些类的地方,在那里要序列化的实例实际存在。请提供更多代码 - 您在哪里使用这些类,以及您实际上序列化的是什么。 – 2011-03-30 14:37:16