dependency-injection

Dependency Injection with unity in default MVC breaks sign in

蓝咒 提交于 2019-12-25 07:59:14
问题 I'm writing a web app and I have used the default Microsoft MVC site as a starting point. After this I created a database of recipes to use in my web app using entity framework and have written a repository and some business layer methods. I then used dependency injection with Unity to remove the coupling between them. I used this code placed in the MvcApplication class in global.asax.cs. private IUnityContainer Container; protected void Application_Start() { AreaRegistration.RegisterAllAreas

What did I get wrong, DI or Design, and how should I go about it?

北战南征 提交于 2019-12-25 07:58:52
问题 To make a long story short, the application that I am currently writing ought to impersonate the current logged in user. It's an application to manage information inquiries. Because of NHibernate.ISessionFactory not allowing more flexibility at the level of its connection string, I need to build the connection dynamically using the current user credentials. (By the way, I'm not complaining against NH, it's a wonderful that I use on each project.) So, I need to force authentication at start up

ZF2 injecting InputFilter into Fieldset not working automatically

不羁的心 提交于 2019-12-25 07:58:49
问题 I'm building a small application with ZF2 and Doctrine2. Setting it up in such a way as to have a lot of reusable code and technique. However, getting stumped by the fact that my InputFilter is not automatically injected into the Fieldset that it should get associated to. I've confirmed that the Form that uses the Fieldset works (without the InputFilter ). The InputFilter is also visible as present during debugging. The question then, what am I doing wrong and how to fix having a separate

Activity graphs and non-found dependency

白昼怎懂夜的黑 提交于 2019-12-25 07:39:05
问题 I'm starting using the dagger, like it pretty much, but now facing some difficulties. My scenario is as follows: there's an activity and a dependency for it. Dependency is injected to the activity, and requires a reference to that activity. Just like this: public class MainActivity extends BaseActivity { @Inject ScbeHelper scbeHelper; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... } } public class ScbeHelper { protected static final

Inject a service into another service

大憨熊 提交于 2019-12-25 07:17:15
问题 I would like to inject a service into another service but, for some reason, the "@Inject" decorator is being ignored. For example, the following service depends on another service: @Injectable() class MyService { final AnotherService _service; MyService(@Inject(AnotherService) this._service); // ... more methods } Angular2 throws the following error: ORIGINAL EXCEPTION: No provider for AnotherService! Am I using the "@Inject" decorator in a bad way? 回答1: Some information is missing to fully

Inject a service into another service

前提是你 提交于 2019-12-25 07:16:17
问题 I would like to inject a service into another service but, for some reason, the "@Inject" decorator is being ignored. For example, the following service depends on another service: @Injectable() class MyService { final AnotherService _service; MyService(@Inject(AnotherService) this._service); // ... more methods } Angular2 throws the following error: ORIGINAL EXCEPTION: No provider for AnotherService! Am I using the "@Inject" decorator in a bad way? 回答1: Some information is missing to fully

ZF2 Dependency Injection of Module Service without Bootstrap.php

与世无争的帅哥 提交于 2019-12-25 05:30:07
问题 I am trying to create an instance of a service which I have implemented in ZF2. Module.php namespace ProductImage; use Zend\Db\ResultSet\ResultSet; use ProductImage\Model\ProductImageStorage; use ProductImage\Service\ProductImageService; use Zend\ModuleManager\Feature\ServiceProviderInterface; use Zend\Db\TableGateway\TableGateway; use ProductImage\Model\ProductImageTable; use ProductImage\Model\ProductImage; class Module implements ServiceProviderInterface { /* Invoked by Module Manager */

Injecting dependency to a Spring bean

隐身守侯 提交于 2019-12-25 04:47:10
问题 I would like to inject a singleton object dependency to a Spring bean. The catch is that I can't access and modify the class whose object I want to be injected. Let me describe on the example. So I have my interface, and the implementation of this interface, like the following. public interface MyServiceProxy { String BEAN_NAME = "MyServiceProxy"; Data getData(String dataId); } public class MyServiceProxyImpl implements MyServiceProxy { private final MyServiceClient client; public

Injecting dependency to a Spring bean

守給你的承諾、 提交于 2019-12-25 04:47:05
问题 I would like to inject a singleton object dependency to a Spring bean. The catch is that I can't access and modify the class whose object I want to be injected. Let me describe on the example. So I have my interface, and the implementation of this interface, like the following. public interface MyServiceProxy { String BEAN_NAME = "MyServiceProxy"; Data getData(String dataId); } public class MyServiceProxyImpl implements MyServiceProxy { private final MyServiceClient client; public

How do I specify the class instance I want my Controller's constructor to receive (when working with Web API, DI, and Castle Windsor)?

不想你离开。 提交于 2019-12-25 04:33:31
问题 Perhaps my questions here and here are not clear enough, so I'll try to decrease the verbosity while not reducing the clarity. Say my Controller uses DI (you can verbalize it "in your head" - you don't have to utter it out loud); so it could look like this: private readonly IDepartmentRepository _deptsRepository; public DepartmentsController(IDepartmentRepository deptsRepository) { if (deptsRepository == null) { throw new ArgumentNullException("deptsRepository is null"); } _deptsRepository =