以下のように構築された ClassToSerialize をシリアライズおよびデシリアライズする方法を見つけようとしています:
[Serializable]
public interface IFoo
{
}
[Serializable]
public class BaseFoo : IFoo
{
}
[Serializable]
public class Foo1 : BaseFoo
{
public string Foo1_Member1 { get; set; }
public int Foo1_Member2 { get; set; }
}
[Serializable]
public class Foo2 : BaseFoo
{
public IList<IFoo> Foo2_Member3 { get; set; }
public string Foo2_Member4 { get; set; }
}
[Serializable]
public class ClassToSerialize
{
public string Class_Member1;
public IFoo Foo;
}
クラスは API に渡され、デシリアライズ時に Foo1 と Foo2 のインスタンスを再構築して「Foo」プロパティに配置し、チェーンを下って IList< IFoo > または同様のオブジェクトに配置する必要があります。
私はこれに1日かそこらこだわっていて、アイデアがありません!