vendredi 3 novembre 2017

How to use reflection to call a API by string name?

How to call an API in another AppService by string name?

Example: I have an API as below in MyAppService

public class MyAppService : MyAppServiceBase, IMyAppService
    {
        private readonly IRepository<MyEntity> _myEntityRepository;    
        public CommonLookupAppService(IRepository<MyEntity> myEntityRepository)
            {
                 _myEntityRepository = myEntityRepository;            
            }

        public async Task<MyOutput> MyMethod (MyInput input)
            {

            }
    }

How to save MyMethod as a string into the database and invoke it in another app service? I have many methods like this so I don't want to use switch case to call them. I want to save this method assembly name to the database as a string and invoke it when needed. What should I do?





Aucun commentaire:

Enregistrer un commentaire