次のようなコンストラクターパラメーターのタイプを取得できます。
Type type = paramInfo.ParameterType;
次に、この型からスタブ オブジェクトを作成します。可能ですか?私はオートフィクスチャで試しました:
public TObject Stub<TObject>()
{
Fixture fixture = new Fixture();
return fixture.Create<TObject>();
}
..しかし、うまくいきません:
Type type = parameterInfo.ParameterType;
var obj = Stub<type>();//Compile error! ("cannot resolve symbol type")
手伝ってくれませんか?