如何seralize只有在净某些属性?属性、seralize

由网友(你独揽我)分享简介:这是一个Web项目,所以我必须从Web.UI继承的几个类。This is for a web project so i have several classes that inherit from Web.UI.我只想要序列非常特殊的属性(基本上,只有本地属性)I only want to serialize v...

这是一个Web项目,所以我必须从Web.UI继承的几个类。

This is for a web project so i have several classes that inherit from Web.UI.

我只想要序列非常特殊的属性(基本上,只有本地属性)

I only want to serialize very particular properties (basically, only local properties)

我知道了XMLIgnore属性,可以放置在一个属性忽略的项目,但这不会在我的环境中工作,因为这将需要修改,​​我真的不想修改一堆东西(而且很可能不能)。

I'm aware of the XMLIgnore property that can be placed on a property to ignore items, but this won't work in my context since that would require modifying a bunch of stuff that i really don't want to modify (and probably can't).

让我怎么跟XML序列化到不顾一切,除了X和Y或告诉它seralize只是X和Y?

So how do i tell the xml serializer to ignore everything except for X and Y or tell it to seralize just X and Y?

我可以只创建一个字符串生成器或东西我自己的XML,如果这是唯一的办法,就这样吧。不过,我正在寻找将采用内置的XML的东西的方法。

i could just create my own xml in a string builder or something and if that's the only way, so be it. however i'm looking for a method that will employ the built in XML stuff.

感谢

推荐答案

有关自定义序列,您可以从的 ISerializable的 接口,并提供自定义序列相应

For Custom Serialization, you can derive your class from ISerializable Interface and provide Custom Serialization accordingly

阅读全文

相关推荐

最新文章