How to do dependency injection in a dynamically created class?

0

I'm making a gateway for a client project to consume microservices. In this gateway, the way the client will consume the application is through an interface. The implementation of this interface will be created dynamically (at compile time). So I need to know how to inject the dynamically generated class dependency. Example:

[MicroServiceHost("MsProduct")]
public interface IProductService
{

    [MicroService("GetAllProducts")]
    IRestResponse GetAllProducts(List<KeyValuePair<object, object>> parameters = null);


    [MicroService("AddProduct")]
    IRestResponse AddProduct(List<KeyValuePair<object, object>> parameters = null);
}

public class MsProductController : Controller
{
    IProductService _productService;

    public MsProductController(IProductService productService)
    {
        _productService = productService;
    }

    public ActionResult GetAll()
    {
        var request = _productService.GetAllProducts();
        var r = request.Content;

        return View();
    }
}
    
asked by anonymous 09.05.2018 / 21:59

0 answers