リフレクション経由で次のコードを書くことは可能ですか?
var fake = A.Fake<Foo>(
o => o.WithArgumentsForConstructor(new[] { "Hello" }));
oは次のとおりです。
Action<IFakeOptionsBuilder<T>>
WithArgumentsForConstructorの場所:
IFakeOptionsBuilder<T> WithArgumentsForConstructor(IEnumerable<object> argumentsForConstructor);
Foo クラスは次のとおりです。
class Foo
{
public Foo(string s)
{
}
}
私がしたことは:
object fake = typeof(A)
.GetMethod("Fake", new Type[] { })
.MakeGenericMethod(new[] { this.targetType })
.Invoke(null, /* Here I need to pass the lambda. */);