我有大约以下图片:
public class Foo
{
public Foo(Bar bar, String x, String y)
{
this.Bar = bar;
this.X = x;
this.Y = y;
}
[JsonIgnore]
public Bar Bar { get; private set; }
public String X { get; private set; }
public String Y { get; private set; }
}
public class Bar
{
public Bar(String z)
{
this.Z = z;
}
public String Z { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)
我希望以某种方式在反序列化期间将类型为Bar的对象传递给Foo类型的构造函数,即:
var bar = new Bar("Hello world");
var x = …Run Code Online (Sandbox Code Playgroud)