如何seralize只有在净某些属性? [英] How to seralize only some properties in .Net?

查看:79
本文介绍了如何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 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

这篇关于如何seralize只有在净某些属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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