说我正在尝试反序列化具有方法或默认构造函数以外的对象的对象,似乎默认DeserializerBuilder设置无法处理它,并且在反序列化时失败。
我猜测解决方案很简单,也许与IObjectFactory和DeserializerBuilder.WithObjectfactory有关?任何提示将不胜感激。
public void Deserialize()
{
string Input = File.ReadAllText("PairedPoints.txt");
DeserializerBuilder deserializer = new DeserializerBuilder();
List<PairedPoint3D2D> PairedPoints = deserializer.Build().Deserialize<List<PairedPoint3D2D>>(Input);
}
public class point2d
{
public point2d(double X,double Y)
{
this.X = X;
this.Y = Y;
}
public double X { get; set; }
public double Y { get; set; }
}
public class point3d
{
public point3d(double X, double Y, double Z)
{
this.X = X;
this.Y = Y;
this.Z = Z;
}
public double X { get; set; }
public double Y { get; set; }
public double Z { get; set; }
}
public class PairedPoint3D2D
{
public point2d Point2d { get; set; }
public point3d Point3d { get; set; }
}