如何排除序列特定类型的? [英] How to exclude specific types from serialization?

查看:86
本文介绍了如何排除序列特定类型的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跑 SGEN 对我组装一吨的类型。我要排除2种类型的序列化。我似乎并没有能够找到一种方法来做到这一点。

I run sgen against my assembly with a metric ton of types. I want to exclude 2 types from serialization. I don't seem to be able to find a way to do it.

我看到 SGEN 有一个 /类型开关来指定一个特定的类型,但没有排除特定的类型。

I see that sgen has a /type switch to specify a specific type, but nothing to exclude a specific type.

有没有办法从系列化排除特定类型的?

Is there a way to exclude specific types from serialization?

推荐答案

不知道如果你正在寻找这一点,但你可以通过提[非序列化]类定义之前排除你自己的类的序列化。 所以,如果你想排除特定的类型,你将不得不从它继承和创建自己的类

Not sure if you are looking for this but you can exclude your own classes from serialization by mentioning [NonSerialized] before class definition. So if you want to exclude a specific type you will have to inherit from it and create your own class

[NonSerialized]
public class Point
{
    public int x, y;
}

这篇关于如何排除序列特定类型的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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