以下に示すいくつかの追加機能を使用して、実行時にインターフェイスの実装を生成できるライブラリがあるかどうかを尋ねたいと思います。
私がそのようなインターフェースを持っているとしましょう:
interface ICustomer
{
string Name {get;set;}
string IAddress { get;set; }
}
interface IAddress
{
string Street {get;set;}
}
私はそのようなことをしたいと思います:
ICustomer customer = someLibrary.Create<ICustomer>(bool createSubObjects)
whereCreate<T>()
メソッドは、実行時に次のような実装を作成します。
class RuntimeCustomer : NotifyPropertyChanged,ICustomer
//NotifyPropertyChanged would be hand written class
{
string name;
IAddress address = new RuntimeAddress();
//if createSubObjects == false then `IAddress address = null`
public string Name
{
get { return name; }
set { SetProperty(ref name, value); }
}
public IAddress Address
{
get { return address; }
set { SetProperty(ref address, value) }
}
}
class RuntimeAddress : NotifyPropertyChanged, IAddress
{
string street;
public string Street
{
get { return street; }
set { SetProperty(ref,street, value) }
}
}
何かアイデアはありますか?