dependency-injection

How to use AOP from DI Frameworks With C# TestFrameworks? (NOT for the item under test)

流过昼夜 提交于 2019-12-22 08:53:25
问题 My apologies in advance for a terrible title- suggestions welcome! I've been reading about DI and AOP, and I think I grasp the basics; at least for the canonical example of adding logging. I would like to apply this to the test cases we've been creating in NUnit e.g. be able to automatically add entry/exit logging for all test case methods and any 'helper methods' that they call. (And I'm not tied to NUnit- if it's easier in another framework, please let me know.) NOTE- this is not about the

Simple Injector and default AccountContoller dependency issue

点点圈 提交于 2019-12-22 08:49:58
问题 I have problem with Simple Injector in my Web Api project. I user default AccountController generated by VS. public AccountController(ApplicationUserManager userManager, ISecureDataFormat<AuthenticationTicket> accessTokenFormat) In my configuration file I register: var container = new Container(); // This is an extension method from the integration package. container.RegisterWebApiFilterProvider(config); container.RegisterWebApiControllers(config); container.Register<IInitializeService,

Autofac Binding at Runtime

感情迁移 提交于 2019-12-22 08:44:29
问题 I currently use Autofac to do simple constructor injection without any issues. However what I would like to know is how to resolve dependencies at runtime. The example below shows multiple ways in which we can export a document. With simple constructor injection the concrete implementation of IExport is resolved at runtime. However what need to do is to resolve IExport on a user selection from a dropdown list which will happen after the construction of my container. Is there any examples of

MVVM and StructureMap usage

社会主义新天地 提交于 2019-12-22 08:19:05
问题 I have quite a large number of parent-detail ViewModels in my MVVM application. Something like this: SchoolsViewModel +- SchoolViewModel +- LessonViewModel +- PupilsViewModel +- PupilViewModel +- TeacherViewModel +- PupilsViewModel +- PupilViewModel +- LessonsViewModel +- TeachersViewModel And so on... In addition, a single view model can appear in more than one place, depending on whether the user is browsing by lesson or pupil, etc. Each child view model is created by the parent view model,

Dependency injection and life time of IDisposable objects

眉间皱痕 提交于 2019-12-22 08:17:22
问题 I am trying to develop a library using dependency injection approach (with Ninject) and I am having some kind of confusion likely because of my incorrect design. In summary, my design approach is A parent object has a common object. A parent object uses some variable number of child objects. All child objects should use the very same common object instance with their parent object Here is a simple model of my problem domain. interface IParent : IDisposable { void Operation(); } interface

Symfony 3.3 injecting repositories into services

我与影子孤独终老i 提交于 2019-12-22 08:01:25
问题 I have a bundle which is held in a private Satis repository as its entities and repositories are shared between multiple application. The rest of the applications that consume that bundle are Symfony 2.7 and 2.8 applications. I'm working on a new application and the requirement is to use Symfony 3.3. In the symfony 3.3 application I have tried this in my services.yml: # Learn more about services, parameters and containers at # http://symfony.com/doc/current/service_container.html parameters:

SimpleInjector mixed lifestyle for per web request and lifetime scope

我的未来我决定 提交于 2019-12-22 08:01:07
问题 I am using Simple Injector as my IoC container and employ the following technique to enable registering a "mixed" lifestyle for some objects as both per web request or per thread. interface IUnitOfWork { } interface IWebUnitOfWork : IUnitOfWork { } interface IThreadUnitOfWork : IUnitOfWork { } class UnitOfWork : IWebUnitOfWork, IThreadUnitOfWork { } container.RegisterPerWebRequest<IWebUnitOfWork, UnitOfWork>(); container.RegisterLifetimeScope<IThreadUnitOfWork, UnitOfWork>(); container

Child container registration based on route parameters

∥☆過路亽.° 提交于 2019-12-22 06:52:41
问题 We have a multi-tennant ASP.NET MVC application that hosts a booking engine for multiple clients. Each of these clients has multiple packages that can influence Unity Container configuration. We are creating a child container per request and registering different interface implementations based on the client and package parameters passed through the route. Currently we are accomplishing this by doing the following: Controller has a property ServiceLocator that uses a unity container to

MVC, DI (dependency injection) and creating Model instance from Controller

喜夏-厌秋 提交于 2019-12-22 06:36:35
问题 My Dispatcher is "choosing" correct Controller; then creating Controller's instance (DependencyInjectionContainer is passed to Controller constructor); then calling some Controller's method... class UserController extends Controller { public function __construct(DependencyInjectionContainer $injection) { $this->container = $injection; } public function detailsAction() { ... } } DependencyInjectionContainer contains DB adapter object, Config object etc. Now let's see what detailsAction()

Could not autowire method

左心房为你撑大大i 提交于 2019-12-22 06:29:27
问题 I am getting this error org.springframework.beans.factory.BeanCreationException: Could not autowire method: This is my spring's xml configuration. <bean ...> ... <property name="InfoModel" ref="InfoModel"></property> </bean> Here is my code where I am autowiring this in Java class private InfoModel infoModel; @Autowired public void setInfoModel(InfoModel infoModel) { this.infoModel= infoModel; } Am I missing something. I suspect that I should make an Interface of InfoModel in order to make it