首页 新闻 会员 周边

序列化的问题

0
悬赏园豆:5 [已解决问题] 解决于 2013-12-23 21:01

为什么一个类添加了[Serializable]标签就可以序列化,这个标签就是特性吧,内部是怎么实现和判断的,是反射特性来判断的吗,求指教

小跳蚤的主页 小跳蚤 | 初学一级 | 园豆:197
提问于:2013-11-13 10:26
< >
分享
最佳答案
0

[AttributeUsage(AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Class, Inherited=false), ComVisible(true)]

public sealed class SerializableAttribute : Attribute

{ // Methods

[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] public SerializableAttribute();

internal static Attribute GetCustomAttribute(RuntimeType type);

internal static bool IsDefined(RuntimeType type);

}

internal static bool IsDefined(RuntimeType type) { return type.IsSerializable; }

反编译之后的SerializableAttribute定义

里面有IsDefined属性 来标记 是否可序列化  希望能帮到你

收获园豆:3
wolfy | 老鸟四级 |园豆:2636 | 2013-11-13 13:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册