Is Func appropriate to use as a ctor arg when applying Dependency Injection?

前端 未结 7 506
没有蜡笔的小新
没有蜡笔的小新 2021-01-31 12:09

Example:

public class BusinessTransactionFactory  where T : IBusinessTransaction
{
    readonly Func _createTransactio         


        
7条回答
  •  醉梦人生
    2021-01-31 12:34

    Yes, that is perfectly acceptable, although if you are using a container, more and more of them now support auto typed factories which would be preferable.

    • Castle Windsor - Typed Factory Facility
    • Ninject - Factory Extension

提交回复
热议问题