在实现了ISerializable接口后,创建了参数为SerializationInfo info, StreamingContext context的构造函数,可以通过info.GetEnumerator()读取到未实现接口之前保存的文件中的数据。
public BaseActionInfo(SerializationInfo info, StreamingContext context)
{
var enumerator = info.GetEnumerator();
while (enumerator.MoveNext())
{
Trace.WriteLine(enumerator.Name);
var name = enumerator.Name;
var value = enumerator.Value;
}
IsExecuted = info.GetBoolean("IsExecuted");
Remark = info.GetString("Remark");
ID = info.GetString("ID");
Name = info.GetString("Name");
Title = info.GetString("Title");
Variable = info.GetString("Variable");
Operation = info.GetString("Operation");
FatherAction = info.GetValue("FatherAction", typeof(BaseActionInfo)) as BaseActionInfo;
FatherActionList = info.GetValue("FatherActionList", typeof(List<BaseActionInfo>)) as List<BaseActionInfo>;
}