How to call an API in another AppService by string name?
Example: I have an API as below in MyAppService
public class MyAppService : MyAppServiceBase, IM
You can use a combination of:
Type.GetType(string)
Type.GetMethod(string)
IIocResolver.ResolveAsDisposable(Type)
— by ABPMethodInfo.Invoke(Object, Object[])
// var appServiceName = "MyAppService";
// var methodName = "MyMethod";
// var input = new object[] { new MyInput() };
var appServiceType = Type.GetType(appServiceName);
var method = appServiceType.GetMethod(methodName);
using (var appService = IocResolver.ResolveAsDisposable(appServiceType))
{
var output = await (Task)method.Invoke(appService.Object, input);
}