ioc-container

Castle Windsor: master controller not resolving the registered components in the container

Having the code below in my Global.asax.cs and two controller (one based on a the other: MasterController) I don't seem to find how can I resolve the repository register in my WindsorContainer from the MasterController... the same applies in the HomeController and works perfectly... what am I doing wrong? Global.asax.cs: private IWinds...

How do I use Dependency Injection with wicket?

How do I convert the following example to use one of the wicket/IOC integration packages? I want to learn and understand the DI/IOC pattern. I have read a lot about it, but I've found it a little hard to grasp without digging into a code example. I have an example of a complete, working Wicket panel, which I think I want to convert to u...

Unity IoC and registering primitive types

Right then, I've run into a situation using Unity that I don't know how to solve/approach...Here's my problem. I'm developing a WPF application and I'm using MVVM (Prism Implimentation hence the Unity container). I have a ViewModel called MenuItemsViewModel (plural) which contains an IEnumerable of MenuItemViewModel (singular). In the...

Windsor container components not available on first controller action

Hi there, I'm using a configuration within the global.asax.cs to register the components but it looks the container hasn't been initialized yet at the first http request (HomeController > Index action) and it gives me a "The ObjectContext instance has been disposed and can no longer be used for operations that require a connection." erro...

Does this code smell?

Please educate me if I have code smell (violating SOLID principles, etc) Also how can I make use of IoC to make dependency injection better? Any help, tips, feedback is REALLY appreciated :) EDIT: Should all dependencies be injected from the constructor in the form of strings or should they be interfaces, if possible? For example, Logi...

Should I use objects passed to Constructor during Injection?

I understand one of the (maybe best) ways of using inversion of control is by injecting the dependent objects through the constructor (constructor injection). However, if I make calls to these objects outside of the object using them, I feel like I am violating some sort of rule - is this the case? I don't think there is any way of prev...

IoC (StructureMap) Best Practice

By my (likely meager) understanding, doing this in the middle of a method in your controller / presenter is considered bad practice, since it creates a dependency between StructureMap and your presenter: void Override() { ICommentForOverrideGetter comm = StructureMap.ObjectFactory.GetInstance<ICommentForOverrideGetter>(); since th...

DataServiceContext in WPF ViewModels

Hi, So I have a WPF application accessing entities through WCF Data Services. At the moment, I am accessing the proxy class that implements the DataServiceContext directly in my ViewModel. For example: this.context = new MyOwnDataServiceContext(new Uri("http://localhost/myowndataservice")); I then populate entities on the ViewModel f...

Why to use a IoC framework

Hi, I've been reading about Inversion of Control frameworks and I'm just playing around with the question: "Why in the hell do I need a framework to do this?" Don't misunderstood my question... the pattern is something we programmers use often but... a full featured framework to do that? I must be missing something and that's the reaso...

Does Queryability and Lazy Loading in C# blur the lines of Data Access vs Business Logic?

I am experiencing a mid-career philosophical architectural crisis. I see the very clear lines between what is considered client code (UI, Web Services, MVC, MVP, etc) and the Service Layer. The lines from the Service layer back, though, are getting more blurred by the minute. And it all started with the ability to query code with Linq...

how to create a Spring bean from a static inner class constructor?

I am trying to use the Spring Framework IoC Container to create an instance of class ThreadPoolExecutor.CallerRunsPolicy. In Java, I'd do it this way... import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; ... RejectedExecutionHandler rejectedExecutionHandler = new ThreadPoolExecutor.Cal...

StructureMap 2.6 - How to do this in configuration file

Hi, Here is the c# code: var server = ******* some internal logic to determine server name **** var username = ******* some internal logic to determine user name **** var password = ******* some internal logic to determine password **** ObjectFactory.Initialize(x => { x.For<IService<bool>>(...

How to use Ninject2 with WCF?

Hi all, In a short view of the IoC and DI .NET libraries I chose to use Ninject2. According to DDD style in: Infrastructure: I have Entity Framework 4.0 .edmx model and the Repository implementation Domain Layer: I have POCO objects and Repository Interfaces (implemented in Infrastructure) Application Services: I have WCF services tha...

Unity Static Factory Extension

I can't seem to find Microsoft.Practices.Unity.StaticFactory.dll anywhere. Is there another way of registering a static factory? Looking for something like this container.RegisterFactory(()=> FooFactory.CreateFoo()); ...

Resolve generic service

I got the following service: IRepository<TEntity, TPrimaryKey> ..for which I've created an implementation defined as: Repository<TEntity, TPrimaryKey>. How do I register it in autofac so that I can resolve it as: IRepository<User, int> ...

What is a good pattern for multi-threading in an IOC application (windsor)

I'm writing a simple photo downloader application using IOC. There is a fairly straightforward list of steps. Get list of photos to download. Check this, Check that, then download. The download can be accomplished via FTP in some cases, and via http in others, and via a web service in others. What I'm wondering, as I'm new to IOC ...

Castle Windsor, how to programmatically mimic the parameter xml syntax

Given this legacy XML configuration for Castle Windsor: > <parameters> > <AdditionalMessage>#{message}</AdditionalMessage> > <Files>#{files}</Files> > <downloaders> > <array> > <item>${HttpFileDownloader}</item> > <item>${HttpsFileDownloader}</item> > <item>${FtpFileDownloader}</item> > ...

Get multiple new instances with 0 coupling to Guice

I created a class that uses the the Java Executor API to create/manage a pool with fixed number of threads. Each thread needs a new instance of a particular object, and I would like to inject this object with Guice. For the moment I'm using a Provider which provides new instances of the object through its get() method. But now this clas...

StructureMap default instance overloading with explicit arguments, error 205

I have a class: public class SystemQuery<T> : ISystemQuery<T> where T : class, IUIView { protected ISession session; protected ICriteria baseCriteria; public SystemQuery(SessionContext sessionContext) { this.session = sessionContext.Session; this.baseCriteria = session.CreateCriteria<T>(); } publi...

UnityContainer usage and best practices

Hello, Is it wrong to use UnityContainer in an app to access references to objects from different parts of the application (but the same assembly)? The application (WPF) has several regions that need to access each other and I have used UnityContainer to do that. For example, the "main" region (which is a drawing area) has a presenter...