ioc-container

structuremap objectfactory life time

Hi, i've been using structuremap since a couple of months. I always use ObjectFactory.GetInstance to take the right instance of the object i've to use. Actually, i need to understand which is the default ObjectFactory's InstanceScope. Is it ThreadLocal? do u know where i can read about it? ...

Satisfying Child View Model Dependencies

Hello, I'm building a master-detail form. The master view model constructs instances of the details view model. These details view models have several dependencies which need to be satisfied with new class instances. (This is because they need service layers that operate in a separate data context from the master vm.) What would be the...

What is a correct approach to register several inctances for the same type in Windsor Container?

I am using CommonSrviceLocator with WindworContainer for resolving my NHibernage.ISession instances. ISession instances is created through SessionFactory. For some reason I need to work with different databases in one application, so I need different connection strings and different NHibernate.ISession objects. SessionFactory can create...

What should be injected as C'tor paramter under DI principles ?

I'm trying to understand which objects should be injected into an object and which should be created internally. If i have some List<int> (as data field) which holds infomation gathered during run time. it seems that i should init it in the c'tor instead of injecting it. but what about a hardware class which communicates through a CO...

How to resolve a named instance from a static class?

Does anyone have any idea about what i doing wrong? I have a such static class: public static class ApplicationContainer { private static ContainerBuilder builder = null; private static IContainer container = null; public static void Create() { builder = new ContainerBuilder(); builder.RegisterInstance...

Registering generic types and services with Castle Windsor IoC

Hello again stackoverflowians, I thought it was about time that I learnt how to use a DI framework. I've heard a lot of good things about Castle Windsor so I decided to go with that. Now there are PLENTY of tutorials out there on how to use it, however, I cannot find much useful information about what to do when Generics get involved....

Set AutoFac to use PropertiesAutowired(true) as default?

Is there a way i can set AutoFac to use PropertiesAutowired(true) to be the default for all types being registered. i.e. I dont want to use ".PropertiesAutowired(true)" all the time var builder = new ContainerBuilder(); builder.RegisterType<Logger>() .PropertiesAutowired(true) .SingleInstance(); ...

ioc - castle windsor in asp.net mvc 2 + data context + connection string

I'm using castle windsor in asp.net mvc 2, with a separate project for the domain model which contains datacontext (dbml), I've deleted the app.config in the domainmodel project getting the following error: Can't create component 'DomainModel.Concrete.ArticleRepository' as it has dependencies to be satisfied. DomainModel.Concrete.Arti...

Where to store Ninject IKernel in a web application?

I am new to IOC in general and I'm struggling a little to understand whether what I am trying to do makes any sense. I have a web forms application in which I want to create one module to define some bindings for me. The bindings will be used to inject repositories into my business manager classes, allowing me to unit test the business...

Can I register my types in modules in Unity like I can in Autofac?

I am fairly familiar with Autofac and one feature that I really love about Autofac is the registering of modules. Does anyone know how I can do this with Unity? I'm having a hard time finding which terms to use in Google to come up with the unity equivalent if there is one. public class Global : HttpApplication, IContainerProviderAc...

Unity / EntLib: Injecting a dependency into a CustomTraceListener

Sorry, this is quite a special topic so this may not be of interest to many. :-( However, I need to do the following thing: I have an application that provides logging to some kind of console window (it's a WPF window, because of application requirements and because the application needs to look flashy even here - our special customer...

WCF Data Services (oData): Dependency Injection with DataService

How can I use my IoC container in a DataService and the CurrentDataSource inside for WCF Data Services? I have several services I want to pass into it. The "host" application or project for the DataService is based on ASP.NET MVC 2.0. My IoC container is setup in the MvcApplication. ...

Tracking instances created by a MEF container.

Hello, I'm using MEF to create several instances of the same export. I'd like to keep track of the instances I have created, and am either querying the container or using a recomposited collection, but I never get my instances... Here's the code: interface IFoo{}; [Export(typeof(IFoo)),PartCreationPolicy(CreationPolicy.NonShared)] cl...

Why doesn't the following mocking with Ninject.Moq work?

I'm trying to run the following code with Ninject.Moq: [TestMethod] public void TestMethod1() { var kernel = new MockingKernel(); var engine = kernel.Get<ABC>(); //as I don't need to actually use the interfaces, I don't want //to even have to bother about them. Assert.AreEqual<string>("abc", engine.ToString()); } A...

How, for example, to make a binding with constructor arguments to a Bitmap with Ninject?

I currently have a class of this form: class Abc { private readonly IDisposable disposable; public Abc(IDisposable disposable) { this.disposable = disposable; } ... } Now, I'd like to know how can I make a binding of IDisposable to Bitmap using the Bitmap(int widht, int height) constructor. I've tried w...

Construtor/Setter Injection using IoC in HttpHandler, is it possible??

Hi. I've ran into a rather hairy problem. There is probably a simple solution to this but I can't find it! I have a custom HttpHandler that I want to process a request, log certain info then enter the details in the database. I'm using NUnit and Castle Windsor. So I have two interfaces; one for logging the other for data entry, which a...

Castle Windsor - how to resolve components based on constructor parameters

Hi all, Say I have a component like this public class MyComponent { public MyComponent(string name) { } } I basically want to have the provided constructor parameters behave as part of the component identifier when resolving it. If you've never resolved it with that set of parameters, it will instantiate a new one. In ot...

ASP.NET MVC2 IoC: Looking for an example using CastleWindsor container that works with minimum config

I am looking for an example of how to configure an ASP.NET MVC2 project to use CastleWindsor container to do IoC. I keep running into problems setting it up, and for every problem there seems to be a solution on-line, but in the end I make so many changes and end up with such a verbose setup to get IoC working using CastleWindsor, that ...

Does IOC container makes object's when project is deployed??

How IOC container helps maintaing objects by creating once and injecting when required??? ...

Can I use an IoC container to create ASP.NET webforms pages and controls?

With ASP.NET MVC it is pretty easy to integrate an IoC container to create the controllers. Is the same thing also possible with webforms to create the pages and controls and pass them any dependencies? If yes, where do I have to plug it in? ...