I am finally getting my feet wet with Dependency Injection (long overdue); I got started playing with Unity and run into an issue with the strategy pattern. I can use the container to return to me specific implementations of a strategy based on a name, but what I don't see is how I am supposed to get the right strategy in the context.
Le...
Hi StackOverflow,
Lets assume we've build a system with a DI framework which is working quite fine. This system currently uses JMS to "talk" with other systems not maintained by us. The majority of our customers like the JMS approach and uses it according to our specification. The component which does all the messaging is injected with ...
Hi StackOverflow!
My application requires several interface implementations which require a Jetty server to do their job. This is, however, not necessarily the case in every implementations of those interfaces so the Jetty server is only a dependency.
Since it would be a huge amount of pain to wrap the entire jetty server with all its ...
In past couple of days, I have read about quite a lot about dependency injection/inversion of control/inversion of dependency. I think that, now my understanding of the concept is much better. But I still don't get the following from wikipedia:
A. High-level modules should not
depend on low-level modules. Both
should depend on ab...
I have an ASP.NET page that implements my view and creates the presenter in the page constuctor. Phil Haack's post providing was used as the starting point, and I'll just the examples from the post to illustrate the question.
public partial class _Default : System.Web.UI.Page, IPostEditView {
PostEditController controller;
pub...
Our project is using constructor-based Dependency Injection (we're using Unity as our container) and we have a number of constructors which have acquired a large number of parameters.
For example:
public FooRequestService(
ITransactionDataBuilder transactionDataBuilder,
IMapper<SaveFooRequest, FooRequestMessage> sav...
Packaging Controllers, Services,etc. i.e.
- com.company.controllers
- com.company.services
Is this a good practice or should be avoided by all means??
Another worth mentioning problem I encountered is in naming services Example
SomthingGatewayService.groovy can't be initialized in both these ways
- SomthingGatewayService somtinggatew...
Let's say I have a common WCF service and console app project that do not change across client specific deployments. I have some interfaces in the common projects that are implemented by specific client code. The client code obviously changes from client to client. I'm thinking this would be an appropriate use for an IoC container. In my...
Assuming I want to use a dependency injection framework in an AOP approach, with the goal of producing code modules. What's the best practice for the ownership of the shared interfaces? By ownership I mean the body of code that needs to be referenced in order to use the interface.
My first guess is that in AOP you would define a class...
I'm starting out with MVVM, and I'm starting to understand things. I'm currently experimenting with the Cinch framework, though I'm not committed to it as of yet.
I was injecting the ViewModels into the Views using by having a reference to the ViewModel in the codebehind of the view, with the property having a [Dependency] on it, and in ...
We've been experimenting with StructureMap, and I'm having trouble grasping how to handle situations where a single interface has multiple implementations. The code below shows an example where we have two databases that are both accessible from a single service.
public class SomeController : Controller
{
private ISomeService _servi...
Firstly, I'm starting to use StructureMap, but an example in any DI framework will do.
I have a class as so,
public class GeoData
{
public List<Country> GetCountries()
{
IDbConnection con = new SqlConnection(ConfigurationManager.ConnectionString["GeoDataConnection"])
//Sql stuff to return countries from a database...
I have setup unity in my project and it is working for objects that don't have constructor injection implemented on them. The issue is now I do have an object which requires a custom object as a constructor argument. I have set up the config below, and this errors telling me that
"TypeConverter cannot convert from System.String"
<unit...
Hi, I'm refactoring the controllers in a .net MVC app so I can inject the dependencies using the unity container. There's this service that needs a reference to the controller's modelstate so I'm hitting a roadblock here. Is it possible to get a reference to the controllers's modelstate at the time of the injection? I'm currently registe...
I'm wondering how I should store/reference my dependency injection container(s). Is it alright to have a container be a static property on a static class? Or should I have the container be an instance variable on the application? I'm wondering what the pros and cons of each option are, and what is the best practice for this in web, mvc, ...
Hello stackoverflow! Long-time reader first time writer here. I am currently undertaking a conversion from to the use of Ninject to the current release of Castle Windsor for a simple C# .NET application.
For the most part, the conversion has gone well and the implementation of the containers has executed flawlessly. I am however hav...
Hi,
is there a way to use dependency injection to inject all available implementations of a specific interface in spring?
This is kind of the same thing as asked here for .NET.
Though my aim is to use @Autowired for this:
public class Foo{
@Autowired
private IDataCollector[] collectors;
}
Is this supported, would this require h...
So I'm starting to use Ninject for dependency injection and I'm wondering what people think of using a kernel as an object factory for Unit of Work type objects like Linq2Sql Datacontexts. I would just inject them like normal dependencies, but this introduces some object lifetime issues I'd like to avoid. DataContexts are different tha...
I've been searching for guidance for using IoC containers in domain driven design. Evan's book unfortunately doesn't touch on the subject. The only substantial guidelines I could find on the internet is here.
Many of Malovic's points are common sense but I'm concerned about a few of them. He suggests that IoC container's should be reser...
I need to build a 'customizable' asp.net web application (not asp.net mvc).
I was thinking to use an IoC container to inject user control into aspx pages.
Has anybody ever tried that ?
In brief here is how I think this can be achieved:
I use Scott Guthrie's method to build a reusable 'user control library' (see his article "Creating...