Unity を使用してクラスのメソッドを呼び出しています。これに対する私のヘルプ クラスは次のようになります。
protected T Using<T>() where T : class
{
var handler = ServiceLocator.Current.GetInstance<T>();
if (handler == null)
{
throw new NullReferenceException("Unable to resolve type with service locator");
}
return handler;
}
クラスのメソッドを呼び出すには、このコードを使用します
Using<FooService>().Get(parameter);
しかし、リフレクションを使用してクラスとメソッドを取得できますか?
例
string className = "FooService";
string methodName = "Get";
string parameterName = "Parameter"
Using<className>().methodName(parameterName)