ioc-container

Unity (in PRISM) does (not) weird resolving...??!!

Hi everybody! I 'm using PRISM and in the Bootstrapper class i did override the ConfigureContainer() method. There is nothing fancy in it just these lines: protected override void ConfigureContainer() { Container.RegisterType<IDataContext, SQLDataContext>(new InjectionConstructor(@"Server=localhost\SQLExpress;User Id=...

Inversion of control domain objects construction problem

Hello! As I understand IoC-container is helpful in creation of application-level objects like services and factories. But domain-level objects should be created manually. Spring's manual tells us: "Typically one does not configure fine-grained domain objects in the container, because it is usually the responsibility of DAOs and business...

prepopulate MVC Models with IOC - an alternative to caching?

Hello, I'm considering strategies for a simple-minded CMS implementation for an ASP.NET MVC site. The simple-minded part is that I've abstracted the values used in various partial views, all of which are user controls that share identical CSS layouts. So I'm populating the custom values in the identical partial views from the database ...

Parameterized controller constructor never gets hit

With my pet project I'm trying to learn to use Turbine as a DI container. I'm registering unity as locatorprovider as such: static MvcApplication() { ServiceLocatorManager.SetLocatorProvider(() => new UnityServiceLocator()); } My user repository has a parameterless constructor and I'm registering it as such: public class UserRep...

MEF: Where should I put the CompositionContainer?

Hello Everyone, I have been using the Windsor IoC Container for my web-based application, to resolve the data access layer implementation the application should use. The web application's UI will consist of pages, and each page consists of small units called portlets. (Their concept is somewhat similar to widgets.) These so-called port...

Castle - Using Factory Method and Transient Lifestyle

I have the following code in my application start method along with the code to setup the container and factory support. The factory method seems to only be called once instead of every time the session is needed. _container.Kernel.Register( Component.For<ISession>().LifeStyle.Transient .UsingFactoryMethod(() => { //...

Unity framework with configuration file and singleton classes.

Hi, so the store goes like this. I have singleton class (a.k.a ServiceLocator) which you can get the instance using the "CreateInstance()" method. At the same time, we added Unity into our application and configure it using the standard configuration file. The problem started when i was trying to map interface IServiceLocator to get th...

Map singleton to Interface using unity framework (config file)

Hi, is there is anyway to map/register singleton, using the unity configuration file, and map it to an interface while the singleton doesn't expose any public constructor? Please advice, Thanks ...

Could not resolve serviceType [controller name]

When trying to refactor an existing asp.net-mvc application to use Turbine as an IoC I get the following result: MvcTurbine.ComponentModel.ServiceResolutionException Could not resolve serviceType 'CommonProject.Web.Shared.Controllers.SearchController' Source Object: at MvcTurbine.Unity.UnityServiceLocator.Resolve[T](Type type) The ...

Lifetime management in mvc turbine?

How can I manage the lifetime of my services in mvc turbine (using Unity)? I have an ISearchService implementation LuceneSearchService that takes an IConfigurationService and ILoggerService. Currently my searchservice registration looks like this: public class SearchServiceRegistration: IServiceRegistration { public void Registe...

Unity IOC Static Factories

Is there a way via xml configuration to denote a static factory method on an object? ...

IOC container working with asp.net mvc 2.0

Is there any IOC container that already implements a controller factory compatible with asp.net mvc 2.0 ....if so i'll move my projects to 2.0 to test... Anyone know a good reference about it? ...

firsts steps with an IoC because I hit a wall, please explain the 'behind the scenes'

So I started this new project, and I was trying to incorporate all the new design principles I was reading about, namely trying to make things loosely coupled, testable, and following some patterns. So I then ran into the issue of having to pass too many factories/managers into my classes constructor, which led me into Dependancy inject...

InjectableFilterAttribute never hits the Filter

On my base controller I have placed the Logger attribute. This LoggerAttribute looks like this: public class LoggerAttribute: InjectableFilterAttribute { public override Type FilterType { get { return typeof (LoggerActionFilter); } } } The ctor on this loggerattribute gets hit, but the FilterType getter not. The r...

Setting the parameterless constructor as the injection constructor in container creation

I have a class with two ctors. One parameterless and one with parameters. Unity will by default take the gready approach and go for the last ctor. How can I define what ctor to use (I want to parameterless) without adding dependency on Unity within my classes? I think it is possible to do it in my container creation, but I don't know ho...

StructureMap Error 202 Setting up IOC container

Hi, I'm getting an error: StructureMap Exception Code: 202 No Default Instance defined for PluginFamily MVCPoco.Services.IService, MVCPoco.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Line 96: { Line 97: Type controllerType = base.GetControllerType(context, controllerName); Line 98: r...

Generic Repository Structuremap IOC question

Hello guys, I'm new to IOC and strcturemap but i want to know how I can register different classes that implements from the same interface like IRepository that implements CustomerRepository and CategoryRepository for example. And, as you can see, if i can use this with generic types. Like Repository or Repository x.ForRequestedType<IRe...

Can Castle.Windsor do automatic resolution of concrete types

We are evaluating IoC containers for C# projects, and both Unity and Castle.Windsor are standing out. One thing that I like about Unity (NInject and StructureMap also do this) is that types where it is obvious how to construct them do not have to be registered with the IoC Container. Is there way to do this in Castle.Windsor? Am I bein...

How to change configs in Spring.Net

An advantage of an IoC container is that you can swap in a mock service at the bottom of your object graph. However this seems much harder to do in Spring.Net than in other IoC Containers. Here's some code that does it in Unity and has Spring.Net code; namespace IocSpringDemo { using Microsoft.Practices.Unity; using NUnit.Framew...

Using enums with Pococapsule (C++ IoC-container)

Is there a way of supplying enum values as method-args in pococapsule without resorting to factory-methods? Let say I have a class that take an enum value in its constructor class A { A(myEnum val); } Using Pococapsule xml configuration: I would like to express something like this: <bean id="A" class="A"> <method-arg type="M...