Какую роль делегаты играют во внедрении зависимости?

Если Вы просто хотите имена столбцов, то

select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'tablename'

На SQL Server MS, для получения дополнительной информации о таблице, такой как типы столбцов, использование

sp_help 'tablename'
10
задан Edward Tanguay 8 October 2009 в 09:53
поделиться

2 ответа

I know that MEF for example allows injecting delegates. However you can also make an ILog interface that has a Log method with the same signature as your delegate. I think it'll be much clearer to understand that the intend was to inject an implementation of an object capable of logging rather than a single log function.

2
ответ дан 4 December 2019 в 01:57
поделиться

I occasionally use delegates as Anonymous Interfaces - also for DI.

One issue with this approach, however, is that it becomes a little bit more difficult to unit test that the correct Dependency was injected and used in a class, because a delegate instance isn't a type, and sometimes you'd simply just want to verify that a class uses the correct type of Strategy/Dependency.

4
ответ дан 4 December 2019 в 01:57
поделиться
Другие вопросы по тегам:

Похожие вопросы: