1

重複の可能性:
リフレクションを使用して dll 内の特定の基本型のすべてのクラスを取得する

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)
4

0 に答える 0