ioc-container

IOC across visual studio projects?

Hi I'm trying to retro-fit (bad idea I know, but better late than never) IOC and DI into an existing solution. The code base is made of up about 30 projects, each which have classes in them which have little or no visibility to the outside world. Being relatively new to the IOC thing I'm trying to use best practise when reworking the ...

Castle Windsor Component registration of multiple interface on a single service

hello. i am trying to implement multiple Service Contracts via a single WCF. i am trying to run this code: return new WindsorContainer() .AddFacility<WcfFacility>() .Register( Component.For<IServiceBehavior>().Instance(metadata), Component.For<IServiceBehavior>().Instance(debu...

Can the object created in IoC container be called Singleton. If not - why?

can the object created in IOC container can be called Singleton if yes why if no why? Can anybody explain me in detail in simple words how IOC conatiner exactly manages the objects.. ...

How do you register a component in Castle which takes another component as a parameter in code?

What is the correct way to pass another component into Eq()? _container.Register( Component.For<IDocumentManagementServiceProvider>() .ImplementedBy<DocumentumServiceProvider>() .Parameters(Parameter.ForKey("credentials").Eq(?) // <---right here Solution: _container.Register( C...

Castle Keeps giving me a System.TypeLoadException: Method 'myMethod' does not have implementation?

System.TypeInitializationException: The type initializer for 'XXX' threw an exception. ---> System.TypeLoadException: Method 'GetDocuments' in type 'YYY' from assembly 'ZZZ, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.. I am getting the above error when trying to resolve an object with Castle...

How do I use sturcturemap to pass two different implementations of a single interface into a constructor?

I have a constructor that take two interfaces, they are the same interface, but need to be different implementations: public class Foo { public Foo(IBar publicData, IBar privateData) { } } What I'd like to happen is that structuremap would pass in a concrete implementation of IBar as class PublicData and class PrivateData ...

SimpleServiceLocator: Why is automatic constructor injection not supported for singletons?

I've been experimenting with the SimpleServiceLocator, and I like it quite a bit, but there's one thing that I'm really frustrated by--you can't use automatic constructor injection for singletons. To make matters worse, you can't even use automatic constructor injection for its dependencies. You have to create the singleton object, all i...

How could you swap out a particular database implementation in python?

If I have a seperate class for my db calls, and I create another implementation of the db layer but say with a different data store. Is there a way for me to completly swap out the implementation without having to change allot of code? i.e. I am starting a project, so I can design things properly to achieve this from the get-go. Note:...

StructureMap can not find a default instance for HttpServerUtility

I have a class that relies on HttpServerUtilityBase my plan was to get structure map to use HttpServerUtilityWrapper as the default instance. Nothing odd there. However, once I've added the declarations to my registry, structuremap is unable to resolve the instance and I get a 202 error. This is my registry: public class ApplicationReg...

Whose responsibility should it be to register types with the IoC container?

Lets say I have an ASP.NET MVC web application which consists lots of assemblies. Here's a very simple example: MyApp.Web the web app MyApp.Services contains interfaces and implementations of domain services, e.g. IOrderProcessor, DefaultOrderProcessor MyApp.DAL contains interfaces and implementations of repositories, e.g. IOrderR...

AutoMapper classes with a Transient lifestyle in IoC

I'm using AutoMapper to map domain entities to view models in an Asp.Net MVC app. I register these mapping classes in Castle Windsor so they are available to the controller thru ctor dependency injection. These mapping classes has a virtual CreateMap method where I can override AutoMapper's mapping, telling it how to map fields from th...

How to learn Autofac fast for Windows development?

I'm about to start a project where the IoC being used is AutoFac - at a new company. I have no prior experience with DI/IoC and want to get up to speed on this so I don't look toooo unintelligent. This will be for a WPF application (which again I'm not too cluey about but that will be OK) What are some good resources I could use to lear...

In Ninject 2.0, how do I have both a general binding and a binding for a specfic case?

I have a situation where I want to dependency inject my user object, but also place the current user in the IoC container. I want the following lines to work: kernel.Get<User>(); // Should return a new User() kernel.Get<User>("Current"); // Should return the current user One might think bindings like this would work: Bind<User>().To...

Many IoC dependencies in transaction-script type processes - what are we doing wrong?

We have many long-running processes that each require dozens of steps. Each step is relatively complex in its own right, so we broke those steps into their own classes. We are using DI/IoC (StructureMap) to help us make the whole thing testable. This has been working great, but we find ourselves with oodles of dependencies in our cont...

Replacing following code with IoC (Castle Windsor)

If I had the code below what are the best practise / design considersations for replacing it with IoC (we are looking to use Castle Windsor). As the "using" statement is responsible for creating the connection object, you can't inject that directly into the constructor or the method. Note: Using SQL connection as what appears to be a c...

Unity Container ResolutionFailedException when the mapping is correct in the config file

I was using a ServiceLocator which i was DIing with Unity public ServiceLocator(IUserStore userStore, IProdcutsStore productsStore, ...etc) {} public IUserStore UserStore { get { return userStore; } } This all worked fine, but I wanted lazy instantiation of the repositories as they have quite sparse use. So my ServiceLocator n...

Unity Nunit & Rhino Mocks

Hi, could anyone give me a good example of using rhino mocks, nunit, and unity together. I am reading the help on each but there doesnt seem to be any good sample projects of how you would use them together and the way to set up projects /test projects using them. I.e. do you create new ioc containers in your test project which point t...

Unity Framework IoC with default constructor

I'm trying to inject a dependency to my MVC controllers like this private static void RegisterContainer(IUnityContainer container) { container .RegisterType<IUserService, UserService>() .RegisterType<IFacebookService, FacebookService>(); } The UserService class has a constructor like this... public Use...

Why should I prefer StructureMap over Unity?

Why should I prefer StructureMap over Unity? ...

IOC Container Runtime Resolution

I'm trying to find an IOC container that will allow me to have mapping data for a field stored in a database and resolve the interface or object that needs resolved via a string value pulled from the database. Most of the examples I have seen are using interfaces hard coded in code, I want the interface that needs to be resolved to be ...