I've this controller
public class AdminController : Controller
{
private IAdministratorService _administratorService;
public AdminController(IAdministratorService administratorService)
{
_administratorService = administratorService;
}
}
And I've this:
private ModelStateDictionary _modelState;
public AdministratorService(IRe...
Hi! I have a wcf service and on the client i have:
var service = new ServiceReference1.CACSServiceClient()
The actual service code is:
public CACSService() : this(new UserRepository(), new BusinessRepository()) { }
public CACSService(IUserRepository Repository, IBusinessRepository businessRepository)
{
_IRepository = Reposito...
I've configured structuremap successfully but every page search for a controller with name "scripts"
public class StructureMapControllerFactory : DefaultControllerFactory
{
public override IController CreateController(RequestContext context, string controllerName)
{
Type controllerType = base.GetControll...
Using interfaces is a very easy way to remove dependencies, but what happens when one of your classes needs a method not defined by the interface? If you're using constructor injection or a factory, how do you access that extra method without casting? Is this possible?
Here is an example of a factory with this problem. Am I trying to do...
I'm getting my feet wet with DI/IoC and MEF in particular.
I have a web application that has two types of parts (maybe more someday) defined by interfaces which need access to the whole environment. The application has a list with concrete implementations for each type, composed by MEF.
The environment consists of:
several repositori...
I am using Spring's @Component annotation to configure many of the beans in my Spring 3.0 application. I would like to know if it's possible to construct some of these beans lazily - especially the prototype beans?
...
Say I have a nice domain model, using (constructor) DI where needed. Now I want to be able to persist this model, so I start adding infrastructure(Entity Framework) to do this. What happens now is that the persistence framework should be able to initialize your types using your IoC container.
Maybe this is possible, maybe not. Anyway, w...
I have this Spring config:
<bean id="boo" class="com.x.TheClass"/>
The class TheClass implements TheInterface. Then I have this (hypothetical) Java code:
@Autowired
TheInterface x;
@Autowired
TheClass y;
The autowiring of TheInterface works but the autowiring of TheClass fails. Spring gives me a NoSuchBeanDefinitionException fo...
There are some cases in which unit test don't work for the project.
I'm studing the Inversion of Control and Dependency Injection utilities and I would like to know if there are good reasons for use it than for make unit tests easier.
--update
Ok, let's analysis 1 of the cited advanteges: less coupling.
You take out the coupling from ...
I'm trying to introduce DI as a pattern here at work and one of our lead developers would like to know: What - if any - are the downsides to using the Dependency Injection pattern?
Note I'm looking here for an - if possible - exhaustive list, not a subjective discussion on the topic.
Clarification: I'm talking about the Dependency I...
I wonder, if I can inject a list of (stateless) beans, that all implementing a special interface.
For example I've a module contract
public interface ResetService {
void reset(MyContext context);
}
Than I've two modules, that are implementing this interface. And one module, that should call all implementations:
@EJBs
private List<...
I have used the abstract factory pattern to help with Dependency Injection and make my project more unit test friendly. A good couple of times I have come across the point that we should return objects in a ready-to-use state. Doing extra work like getting an object's state from a database makes it harder to test unless we can mock out t...
Hello,
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 ...
Can anyone point me towards some good documentation / code examples on how best to manage the configuration of a DI container in a scenario where you need different configuations sets?
We have a layered, distributed application that has multiple entry points (ie; a website, winforms app, office plugin etc). Depending on how you are usin...
I'm struggling to find a decent walkthrough for this issue, and was hoping that someone could shed some light on this... I've built an application using a ton of Unity and DI, and I need to pull a few components into a web site and run a WCF service now with them. host a WCF service for clients to connect to it instead of having it inclu...
Using Unity in an ASP.Net MVC 2 app I have various dependencies on Controllers instantiated correctly. However, I want to ensure that the current IPrincipal for the user is going to be passed via injection to lower level Services, Repository etc.
Therefore in a lower level service I have something like:
[Dependency] IPrincipal Current...
Currently reading "The Art of Unit Testing" by Roy Osherove. I'm about half way through it and so far it's an awesome book. I'm going to ask everyone to leave IOC containers out of this discussion. He only briefly mentions them (actually states IOC are out of the scope of the book which I don't understand and is one of the few places whe...
Possible Duplicate:
Which C#/.NET Dependency Injection frameworks are worth looking into?
Yes I know this question has been asked many times, but the various frameworks keep evolving, so I would like a fresh answer on the subject.
A few thoughts about the framework, they are not necessary black or white, but rather my prefere...
I am fairly new to Unity, (well, IoC and DI in general), and am having problems configuring it for my use.
I have two interfaces:
public interface ISample { ... }
and
public interface IDerivedSample : ISample { ... }
and a number of concreate classes simular to:
public class UseSample : IDerivedSample { ... }
I am attempting to...
I find that my constructors are starting to look like this:
public MyClass(Container con, SomeClass1 obj1, SomeClass2, obj2.... )
with ever increasing parameter list. Since "Container" is my dependency injection container, why can't I just do this:
public MyClass(Container con)
for every class? What are the downsides? If I do this,...