私は自分のアプリケーションで次のようにコーディングしています:
public class ContentController : ApiController
{
private IUow _uow;
private IContentService _contentService;
public ContentController(
IUow uow,
IContentService contentService)
{
_uow = uow;
_contentService = contentService;
}
その後:
container.RegisterType<IContentService, ContentService>();
私がこのように始めたのは、すべてのインターフェイスを使用してテスト可能にし、Unity などを使用して簡単に変更できるようにする方法を読み続けたからです。
しかし、1 年以上経った今でも何も変更する必要はなく、別のサービスを必要とせずに他の方法でアプリケーションをテストできます。
小さなアプリケーション (< 20 コントローラー) の場合、Unity などを使用する利点はあります。パフォーマンスにいかがでしょうか。それは何かを改善しますか、それとも単に問題を複雑にしますか.