- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在编写自定义序列化程序,我刚刚完成了用于处理 ISerializable.GetObjectData
的部分的实现。但是当我去反序列化信息并将其重新应用于图形时,我没有看到 Set-ObjectData 的等效函数。
如何将 SerializationInfo
数据重新应用到图表中?
最佳答案
按照 ISerializable 的 MSDN 库文档中的描述实现特殊的反序列化构造函数:
The ISerializable interface implies a constructor with the signature constructor (SerializationInfo information, StreamingContext context). At deserialization time, the current constructor is called only after the data in the SerializationInfo has been deserialized by the formatter. In general, this constructor should be protected if the class is not sealed.
例如:
protected Widget(SerializationInfo info, StreamingContext context)
{
// Perform your deserialization here...
this.SerialNumber = (string)info.GetValue("SerialNumber", typeof(string));
}
关于c# - ISerializable.GetObjectData 的反序列化等价物是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16363399/
我目前正在努力保存更大的对象结构,其中包含我正在处理的应用程序中的“项目”所需的所有数据。数据是诸如图片、流文档以及更基本的数据类型之类的东西。 现在,我目前的方法是在我需要保存的对象中包含的所有类上
我有一个类,其中包含我正在序列化的一些数据: [Serializable] public class SomeData { public int NumericField; publi
我必须使用一个旧应用程序,该应用程序使用 binaryFormatter 将应用程序数据序列化为文件流(例如在名为“data.oldformat”的文件中) 没有任何优化,主类已用属性标记 publi
考虑以下类的 POD 类型: public class Price { public decimal OfferPrice { get; set; } } 此类的对象是从服务器检索的,所以让我们用可序
我打算使用序列化来做克隆。我必须让我的类 ISerializable。但是它的父类(super class)和所有引用的变量类呢?我需要让它们全部 ISerializable 吗? 如果我使用 ISe
ISerializable 接口(interface)只提供了一种序列化对象的方法。反序列化进程由构造函数管理。 问题是,构造函数不能返回实例,因为构造函数创建了一个新实例。 在我的实现中,有几个属性
我们的任务非常简单,我们有一个对象图,其中每个对象 (IDItem) 都有一个唯一的 ID。对象图存在两次,在客户端和服务器机器上。 现在我们将一些可序列化的命令传递给服务器。该命令具有一些 IDIt
我正在编写自己的 IFormatter 实现,但我想不出一种方法来解决两种都实现 ISerializable 的类型之间的循环引用。 这是通常的模式: [Serializable] class Foo
我们有一个遗留类A,它是[Serializable],但不是ISerializable。由于各种原因,必须修补此类以实现 ISerializable。 问题是我们仍然需要能够加载旧的保存文件,这些文件
我想为包含相似类型子项列表的 C# 类实现 ISerializable。考虑以下示例: using System; using System.Collections.Generic; using Sy
我很难理解 ISerializable 接口(interface)的必要性......我想我在这个主题中遗漏了一些非常重要的东西,所以如果有人能帮助我,我将不胜感激。 这很好用- [Serializa
我有扩展方法 public static T DeepClone(this T source) where T : ISerializable { .. } 当我添加“where T : I
我正在尝试使用 Iserializable 在 Android 中传递对象,但它返回“无法从 native 句柄激活类型的实例”异常。 下面是我的代码。 [FBUserParcel.cs] using
我正在编写自定义序列化程序,我刚刚完成了用于处理 ISerializable.GetObjectData 的部分的实现。但是当我去反序列化信息并将其重新应用于图形时,我没有看到 Set-ObjectD
我正在阅读 msdn 上的自定义序列化文章:http://msdn.microsoft.com/en-us/library/ty01x675%28VS.80%29.aspx 里面提到了实现自定义序列化
我必须在派生类中实现 ISerializable(以执行一些自定义序列化/反序列化),但父类被标记为 [Serializable]。序列化“有效”(我可以序列化和反序列化而不会出现运行时错误)但看起来
我有一组用户定义的类型,它们已经实现了 ISerializable 接口(interface),现在我想将它们托管在服务器端应用程序中,并通过使用 DataContract 属性标记它们来向客户端公开
我有一个看起来像这样的包装列表: [JsonObject(MemberSerialization.Fields)] public class OrderManager : IEnumerable, I
我对继承类中 ISerializable 的正确实现有疑问。 我有两个类,AbstractBaseClass 及其实现 BaseClass。在实现派生自 BaseClass 的 FinalClass
我有一个类通过 XLINQ 实现它自己的(反)序列化,我会喜欢让我类(class)的客户尝试对我的类(class)进行 XMLSerialze而是调用了我的 XLINQ 方法。 这可能吗? 最佳答案
我是一名优秀的程序员,十分优秀!