inversion-of-control

Is It Possible To Spring Autowire the same Instance of a protoype scoped class in two places

Hi ** changed the example to better express the situation i am using spring 2.5 and have the following situation @Component @Scope("prototype") Class Foo { } class A { @Autowired Foo fooA; } class B { @Autowired Foo fooB; } class C { @Autowired Foo fooC; } i am trying to understand if there is some way to us...

I am looking for a simple yet practical and robust IOC\DI framework for .net

I am going to use it in a project with less-experienced developers so a complex framework such as Spring.NET is not an option. I was thinking about: Ninject Castle Windsor StructureMap Which would present a moderate learning curve without losing flexibility? and another question - where is the correct place to put the configuration?...

Which IOC runs in medium trust

Hi I am trying to get a website running with Mosso that has Castle Windsor as my IOC, however I am getting the following error. [SecurityException: That assembly does not allow partially trusted callers.] GoldMine.WindsorControllerFactory..ctor() in WindsorControllerFactory.cs:33 GoldMine.MvcApplication.Application_Start() in Glob...

What is a good model for IoC + Ribbon?

We are using an IoC model for our WPF tools, and are quite happy with how it's all working out. Now we want to add a ribbon to a new tool we're creating, and I'm running into some design problems. I'm looking for guidance on how plugins in our tool can expose their interfaces to the main window's ribbon. We want to be able to continue ...

Unity register instance and resolve...

I've written a class that has some dependencies it resolves from the unity container. From my main class I create a new object MyObject myObject = new MyObject(); I register it with my Unity Container UContainer.RegisterInstance<MyObject>(myObject, new ExternallyControlledLifetimeManager()); the I create the type that needs this a...

how to get dependencies injected in constructors in Windows Forms

in asp.net-mvc I have the Windsor Controller Factory that injects all the dependencies into the controllers, but how do you get this in Windows Forms ? for example if have this Form1, how am I going to get an instance of Form1, should I use resolve (which is called ServiceLocator and anti-pattern by some ppl)? public class Form1 { ...

Quartz.Net and dependancy injection or calling a job from external dll at runtime

I am trying to evaluate Quartz.Net. I tested it with adding a class which implemented IJob in the executing assembly and it worked. Now I want to develop an Job Scheduler in which I can add jobs at runtime. How to proceed. Edit: If it seems subjective I have following specific question. How to add external class/dll which are unkno...

How to inject an asp.net 2.0 web service reference using ninject

I was trying to inject an asp.net 2.0 good old web service reference but it failed. the failure was when trying to use the injected interface. ...

LightSpeed with IoC/Dependency Injection using Repository Pattern

Does anyone have an example of using LightSpeed with the Repository Pattern using interfaces and dependency injection? ...

DDD, handling dependencies

Boring intro: I know - DDD isn't about technology. As i see it - DDD is all about creating ubiquitous language with product owner and reflecting it into code in such a simple and structured manner, that it just can't be misinterpreted or lost. But here comes a paradox into play - in order to get rid of technical side of application in ...

Influencing AOP with attributes via IoC; code-smell or elegant?

I'm using StructureMap at the moment, generally with convention-based (Scan()) auto-configuration, and I'm looking to add decorator-based caching into the pipeline. If I configure it manually that is fine, but Scan() is just so convenient when you get lots of dependencies... I'm toying with noting cache suggestions on the interface(s), ...

Autofac: How to limit the lifetime of an IDisposable object without passing around the IoC container

I'm currently learning how to use Autofac, and I'm stuck with disposing IDisposable objects deterministically. Let me first present the situation before I'll state my problem. Starting position: Let's say my object model is defined through the following interfaces: interface IApple : IDisposable { void Consume(); } interface IHor...

Does the ObjectDataSource just really suck?

I've never had the need to really ever use any of the .NET Data sources other than the SiteMap datasource however I'm trying to take advantage of the built in CRUD operations on a control which needs to be assigned a data source to correctly work. As I've been working through information online about implementing the ObjectDataSource an...

feeding dependencies to a factory class via IoC?

I have a factory class that decides which of four available subclasses it should instantiate and return. As you would expect, all subclasses implement the same interface: public static class FooFactory{ public IFoo CreateFoo(FooEnum enum){ switch (enum) { case Foo1: return...

[StructureMap] Xml configuration or Configuration through code?

I personally like the option to configure StructureMap from C# code. From what I understand, one of the advantages of DI, is that we can easily swap in a new concrete instance. But, if the configuration is defined in code, then the concrete instances are hardcoded in the dll. So, practically, its as good as having hard coded the depend...

Accessing legacy out-of-container instantiated objects from Spring beans

We have a legacy system where something like a Service Locator is used to instantiate and provide all service objects: class ServiceLocator { ServiceA serviceA; ServiceB serviceB; public ServiceLocator () { serviceA = ...; serviceB = ...; } public ServiceA getServiceA() { return serviceA; ...

IOC best practice: How to best manage dependency graph?

I am doing an MVC project with structuremap as an IOC container. We are doing TDD, and I want to set up my dependencies so that its easy to work with, and so that its easy to test. How should I best set up the graph of dependencies for the below fictional illustrated graph ? ApplicationController Controller AuthenticationService Us...

DI-Container: Howto pass configuration to objects

Sometimes I have classes which need to get some information for construction. I am not talking about references to other objects (which will be injected) but about (for instance) strings which are holding unique information: // Scoped as singleton! class Repository { public Repository( InjectedObject injectedObject, string path ) { ...

How do I replace a switch statement with IOC so I can maintain SOLID principle

I wanted to avoid the switch statement. I have over 30 document types. There is also a possibility I will need to add more document types moving forward. I would rather pass IDocument and have the type specified in the implementation of IDocument. Something else I forgot to mention was ProgressNoteViewModel, LabViewModel ... all inhe...

What should be the strategy of unit testing when using IoC ?

After all what I have read about Dependency Injection and IoC I have decided to try to use Windsor Container within our application (it's a 50K LOC multi-layer web app, so I hope it's not an overkill there). I have used a simple static class for wrapping the container and I initialize it when starting the app, which works quite fine for ...