我正在使用unity进行依赖注入,目前我有很多类都具有属性,并且被大量传递,就像这样:
public class TickerApiAddress
{
public string CoinTicker { get; set; }
public string ApiAddress { get; set; }
public double Notional { get; set; }
}
我想使用一种工厂类为我构建对象,而不是在每个地方都创建这些硬对象,以便以后在单元测试中模拟工厂类的返回结果。
ITickerApiAddress ticker = _tickerApiAddressFactory.Create(cointicker, apiaddress, notional);
对于具有依赖项注入的此类工厂是否有最佳实践?我已经进行了一些研究,但似乎找不到很多人使用DI进行操作的示例。我是否应该对ParameterInfo进行一些包装并使用它?