我可以在不破坏封装的情况下使用依赖注入吗?
这是我的解决方案和项目: 书店 (解决方案) BookStore.Coupler (项目) Bootstrapper.cs BookStore.Domain (项目) CreateBookCommandValidator.cs CompositeValidator.cs IValidate.cs IValidator.cs ICommandHandler.cs BookStore.Infrastructure (项目) CreateBookCommandHandler.cs ValidationCommandHandlerDecorator.cs BookStore.Web (项目) Global.asax BookStore.BatchProcesses (项目) Program.cs Bootstrapper.cs: public static class Bootstrapper.cs { // I'm using SimpleInjector as my DI Container public static void Initialize(Container container) { container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), typeof(CreateBookCommandHandler).Assembly); container.RegisterDecorator(typeof(ICommandHandler<>), typeof(ValidationCommandHandlerDecorator<>)); container.RegisterManyForOpenGeneric(typeof(IValidate<>), AccessibilityOption.PublicTypesOnly, (serviceType, …