I need to be able to, at runtime, load two classes that share an unknown type, like this:
interface IProducer<out A>
{
public A CookOne();
}
interface IConsumer<in A>
{
public void EatOne(A food);
}
The entire list of possible involved types can't be known at compile time because they don't exist yet. The software that uses t...
I have a bunch of java custom tags that use spring managed beans.. since i cant find a way to inject into a custom tag, i created a helper class that provides static methods to "getTheObjectINeedBean()" for all the spring bean objects i need.. I do not like this approach at all.
i really want to be able to inject a spring managed bean ...
Hi there,
It says in the Unity manual...
ParameterOverride can be used only for constructors.
So why are the parameters of methods left out?
Cheers, Ian.
...
Hi,
My application is able to start without a database connection, how do I handle this with IoC and constructor injection?
Example:
public class ApplicationShellPresenter(IRepository repository, IView view)
{
}
When IRepository in this case will be constructed an exception will be thrown due to underlaying DAL cannot find config/f...
I'm having trouble designing classes to best make use of DI / IoC principles, particularly when a class shares a dependency with one of its dependencies (ie. X has dependencies Y and Z, and Y has dependency Z).
An example will probably be useful:
Lets say I have a class that will encapsulate some connection information for my app. Call...
I am building an application which uses an Abstract Factory pattern to allow runtime determination of which subclass of my IHardwareDevice to create based upon how it responds to a request for identification. I might create Hardware1 or Hardware2.
The problem arises in that I want to use a State pattern in these IHardwareDevice objects...
I am trying to write a simple IoC library, and i am going to use it in asp.net websites.
My Question is: Should i cache all the registered objects "i add this in Dictionary<Type, object>" and use the cached objects each request? ,or should i resolve them each time page loads or on a new request?
And does the exist tools such as unity ha...
I am trying to register a generic type in a config file for Unity 2.0 but can't seem to get it right. I have been referring to the MS documentation here : http://msdn.microsoft.com/en-us/library/ff660933%28v=PandP.20%29.aspx#_Generic_Types
The code looks like this:
public interface IRepository<T> where T : class
{
...
}
public cl...
I have to support a new input file format in a system which uses Windsor. I also need to support the old version of the input file during a transition phase.
This will probably be repeated in future, and we'll again need to support the new and the next most recent format.
The import processing is handled by a component, and the new ve...
Does anyone have a list of link(s) on the www for a good list of DI gotchas?
I have been trying to inject controls using DI, in an asp.net webforms app and found that on recursive build up that ViewState is lost.
Also would be helpful a list of articles where the developer needs to be aware to gotchas before taking teh big step in implem...
I'm trying to figure out correct way how to bind something like this with ninject.
interface IMainService
{
void DoStuff();
}
interface IOtherService
{
void DoSomeMagic();
}
abstract class BaseClass
{
//many stuff here
}
class MainClass : BaseClass, IMainService
{
public MainClass(IOtherService s)
{
}
pub...
Hi,
I would like to register some components in my Windsor container before my Facilities load - (so that I can use some the components in the facilities)
I was thinking there should be some way to initialize windsor without a configuration file, register some components, and only then load the configuration? - this would result in tha...
I am in a situation where we need to modify what is being returned from the static repository in a 3rd party open-source application (NopCommerce). The problem is that they use static repositories, so I can't merely inherit an interface and DI my own repository. I'm trying to do this without modifying the NopCommerce code-base... any f...
Hi, How do I find what class is currently bound to the abstract class with Ninject in the following example:
if(conditional)
Bind<IProducts>().To<Products>();
else
Bind<IProducts>().To<SqlProducts>();
Type currentType = 'Type based upon current binding of IProducts'
How can I get the value of currentType.
...
This question relates to my other post.
Ok so after a bit more messing around I decided to do it this way. Which seems to work fine when I run it, although I'm getting the following error in NUnit: Could not load file or assembly 'Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies....
Using StructureMap, is it possible to have a singleton object for each value of an argument?
For example, say I want to maintain a different singleton for each website in a multi-tenancy web app:
For<ISiteSettings>().Singleton().Use<SiteSettings>();
I want to maintain a different singleton object corresponding to each site:
ObjectFac...
I have a question concerning how the Unity container I have set up is resolving controller dependencies. I've been searching around for an explanation of this but haven't found anything that is real clear on the subject. And maybe the answer is staring me in the face... Take a look at the following code that I'm sure many MVC guys hav...
I'm building a J2EE application in which I want to allows plugins. I'm fairly convince of the goodness of IoC framework, and so the application will have one to manage services.
Now, I want to allows plugins to be added as simple JAR dropped in the classpath + perhaps a simple configuration file to edit to activate them, in no way some...
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...
When using a dependency injection container, missing dependencies are detected when you execute resolve. This is at runtime.
This article describes a partial solution. It would help simplify test, debug, and maintenance, but it still requires tests to be executed to validate your behavior (especially if you use the abstract factory su...