dependency-injection

Ninject Kernel Scope

I'm new to Ninject, and I was wondering if the scope of the kernel should be 1 per application. So should I treat the kernel as a singleton? Thanks. ...

Is is possible to programmatically change the resourceProviderFactoryType?

I have a custom implementation of IResourceProvider and ResourceProviderFactory. Now the default way of making sure ASP.NET uses these custom types is to use the web.config and specify the factory like so: <globalization resourceProviderFactoryType="Product.Globalization.TranslationResourceProviderFactory" /> This works perfectly, exc...

How to do dependency injection python-way?

I've been reading a lot about python-way lately so my question is How to do dependency injection python-way? I am talking about usual scenarios when, for example, service A needs access to UserService for authorization checks. ...

Dealing with dependencies between WCF services when using Castle Windsor

I have several WCF services which use castle windsor to resolve their dependencies. Now I need some of these services to talk to each other. The typical structure is service --> Business Logic --> DAL The calls to the other services need to occur at Business Logic level. What is the best approach for implementing this? Should I simp...

Unit test complex classes with many private methods

Hi, I've got a class with one public method and many private methods which are run depending on what parameter are passed to the public method so my code looks something like: public class SomeComplexClass { IRepository _repository; public SomeComplexClass() this(new Repository()) { } public SomeComplexClas...

How do I get property injection working in Ninject for a ValidationAttribute in MVC?

I have a validation attribute set up where I need to hit the database to accomplish the validation. I tried setting up property injection the same way I do elsewhere in the project but it's not working. What step am I missing? public class ApplicationIDValidAttribute : ValidationAttribute { [Inject] protected IRepository<MyTyp...

Is dependency injection possible for JSP beans?

This may be a long shot question.. I am working on an application that is based on JSP/Javascript only (without a Web framework!) Is there a way to have depencency injection for JSP beans? By jsp beans I mean beans defined like this <jsp:useBean id="cart" scope="session" class="session.Carts" /> Is there a way/library/hack to interc...

Passing List of Strings or Array of strings into Unity Injection Constructor (Config-Based)

I cannot seem to get unity working when attempting to pass in an array of strings into a constructor parameter list, while using XML configuration. When I try the following: <typeConfig ...> <constructor ...> <param ... parameterType="System.String[]"> <array> <value.../> <value.../> </array> </param...

Dependency Injection with Custom Membership Provider

I have an ASP.NET MVC web application that implements a custom membership provider. The custom membership provider takes a UserRepository to its constructor that provides an interface between the membership provider and NHibernate. The UserRepository is provided by the Ninject IoC container. Obviously, however, this doesn't work whe...

Dependency Injection for Windows Phone 7

I was trying to use Unity 2.0 beta 2 for Silverlight in my Windows Phone 7 project and I kept getting this crash: Microsoft.Practices.Unity.Silverlight.dll!Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.DynamicMethodConstructorStrategy() + 0x1f bytes Microsoft.Practices.Unity.Silverlight.dll!Microsoft.Practices...

When should I use Dependency Injection and when utility methods?

I have a Java EE project with Spring IoC container. I've just found in Utils class static method sendMail(long list of params). I don't know why but I feel that it would look better if we had separate class (Spring bean with singleton scope) which will be responsible for sending email. But I can't find any arguments which can prove my ...

Define Default constructor Structuremap in a Generic Repository

Hello guys, I have a generic IRepository that has 2 constructors, one have none parameters, other has the datacontext as parameter. I want to define to structuremap to aways in this case use the parameterless constructor. I want a way to create a parameterless contructor, other solutions that I have seen, they create a new Datacontext a...

Dependency Injection in XAML (WPF)

I am creating a new WPF project and we use Microsoft Unity as DI. I am having a user control which is calling a 3rd party service. So now how to inject dependency from the main window XAML for the usercontrol. ...

Simple Inversion of Control framework for Java/Scala

I am looking for a simple to use IoC container for GUI applications written in Java/Scala. It should support Convention over Configuration, lifecycle management, configuration in code (preferably without any XML needed at all), and checking dependencies at compile-time as much as possible. Something similar to Autofac would be perfect....

What does "bean X is injected into bean Y" mean in context of Spring framework

Hello. Seems,that very basic question. Anyway can't get the meaning of next definition from Spring tutorials - "bean X is injected into bean Y" . Does it mean composition relation between classes(when one bean has reference to another)? Or it's something more? Thank you for answer or reference with explanation. ...

Circular dependencies in StructureMap - can they be broken with property injection?

Hi, I've got the simplest kind of circular dependency in structuremap - class A relies on class B in its constructor, and class B relies on class A in its constructor. To break the dependency, I made class B take class A as a property, rather than a constructor argument, but structuremap still complains. I've seen circular dependencies ...

Converting From Castle Windsor To StructureMap In An MVC2 Project

I am learning about best practices in MVC2 and I am knocking off a copy of the "Who Can Help Me" project (http://whocanhelpme.codeplex.com/) off Codeplex. In it, they use Castle Windsor for their DI container. One "learning" task I am trying to do is convert this subsystem in this project to use StructureMap. Basically, at Application_...

How to model dependency injection in UML ?

I have a Contract class. The contract is valid 1 Jan 2010 - 31 Dec 2010. It can be in state Active or Passive, depending on which date I ask the instance for it's state. ex. if I ask 4 July 2010, it's in state Active, but if I ask 1 Jan 2011, it's in state Passive. Instances are created using constructor dependency injection, i.e. they...

What's the correct way to instantiate an IRepository class from the Controller?

I have the following project layout: MVC UI |...CustomerController (ICustomerRepository - how do I instantiate this?) Data Model |...ICustomerRepository DAL (Separate Data access layer, references Data Model to get the IxRepositories) |...CustomerRepository (inherits ICustomerRepository) What's the correct way to say ICustomerReposi...

How do I bind Different Interfaces using Google Guice?

Do I need to create a new module with the Interface bound to a different implementation? Chef newChef = Guice.createInjector(Stage.DEVELOPMENT, new Module() { @Override public void configure(Binder binder) { binder.bind(FortuneService.class).to(FortuneServiceImpl.class); } }).getInstance(Chef.class); Chef ...