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
{
...
In a follow up to Krzysztof’s statement that Windsor does a lot more than other IoC’s, I wanted to understand how these IoC’s stack up against each other and the benefits/additional facilities that castle Windsor provides.
Are there any comparisons? Can someone help me understand the additional features that Castle Windsor provides ov...
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.
...
I am involved with several open source projects which taken together provide an application development framework. The question I have is what mechanism(s) should I provide for integrating them with each other?
On the conceptual level the answer is clear - DI/IoC. The "only" problem is to decide which one. In several installations we us...
I decided to start using Ninject and face an issue. Say I have the following scenario.
I have an IService interface and 2 classes implementing this interface. And also I have a class, which has a constructor getting IService and an int. How can I create an instance of this class with Ninject (I dont want to hardwire this int, I want to p...
How do I tell castle to pick up an interface implementation from the assemblies in the executing directory.
E.g.
How do I tell castle to find an implementation for ILog and then If I drop log4net among the assemblies in the executing directory, it should pick it and use it. Tomorrow if I decide to change log4net to Nlog it should pick...
I have a class that has dependencies that I've wired up with Ninject.
public interface IFoo {}
public class MyObject {
[Inject]
IFoo myfoo;
}
In the real implementation I'm using property injection, but just to quickly illustrate, I'll inject on the field. As I understand, instead of newing instances of MyObject, in order ...
I am looking for suggestions on how to map a single DTO class with a type discriminator to multiple domain classes.
I have my DTO:
public class FooData
{
public Guid Id { get; set; }
public string Name { get; set; }
public string TypeDiscrim { get; set; }
}
public class FooDataRepository
{
public List<FooData> GetAll()...
I am using Unity and Unity.AutoRegistration. This line for Unity:
unityContainer.RegisterType(typeof(IAction<>), typeof(Action<>));
effectively registers every class in the project to IAction/Action:
unityContainer.RegisterType<IAction<ObjectA>, Action<ObjectA>>();
unityContainer.RegisterType<IAction<ObjectB>, Action<ObjectB>>();
uni...
I am writing a small utility for myself so whilst I am using Unity currently, I can change to a different IoC container if it will allow me to get around this problem.
I want to create a class that is given some data when it is created, but is immutable after that, normally I would do this with:
class SomeItem
{
public SomeItem(str...
I know that Concrete Types can be configured with Structure Map the following way:
ForRequestedType<Rule>().TheDefault.Is.Object(new ColorRule("Green"));
This works if you know the type ahead of time. I want to do it at run time, and there does not seem to be a way. Can some one enlighten me? What I want to do is something like the...
I'm an IoC newbie, so I'm wondering if it's even the right tool for the job I want to do.
I'm writing a multi-tenant application, and there are several places that we might want to use different implementations of interfaces based on the organization to which the currently logged-on user belongs.
Say, for example, when a user from ...
Someone on the Herding Code podcast No. 68, http://herdingcode.com/?p=231, stated that IOC containers had no place with Python or Javascript, or words to that effect. I'm assuming this is conventional wisdom and that it applies to all dynamic languages. Why? What is it about dynamic languages that makes IOC containers unnecessary?
...
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...
Hi!
How do I wire structuremap to inject properties when builing instances of interface IDummy.
Let's say that I have a concrete class called Dummy which implements interface IDummy.
The Dummy class got two properties, the first one called DataContext implements IDataContext, the second property is just a basic string called MyDummySt...
I've started playing with Ninject and from a screencast it states the following is how you set up a binding:
class MyModule : StandardModule {
public override void Load() {
Bind<IInterface>().To<ConcreteType>();
// More bindings here...
}
}
This is all very good.
However suppose you have one hundred objects u...
To illustrate the problem, here is a simplified version of my setup.
I have a factory like this one :
public interface IFactory{ }
public class Factory : IFactory
{
public Factory()
{
Console.WriteLine("parameterless");
}
//public Factory(int i)
//{
// Console.WriteLine("with parameter : {0}", i);
...
I have a unity container that I am registering types within like so:
IUnityContainer container = new UnityContainer()
.RegisterType<ITaxAuthorityRateService, TaxAuthorityPopulationRateService>( "PopulationRate" )
.RegisterType<ITaxAuthorityRateService, TaxAuthorityBusinessLicenseRateService>( "BusinessLicenseRate" );
Then I also w...
I work in a VB.Net environment and have recently been tasked with creating an MVC environment to use as a base to work from. I decided to convert the latest SharpArchitecture release (Q3 2009) into VB, which on the whole has gone fine after a bit of hair pulling. I came across a problem with Castle Windsor where my custom repository inte...
I've configured structuremap successfully but every page search for a controller with name "scripts"
public class StructureMapControllerFactory : DefaultControllerFactory
{
public override IController CreateController(RequestContext context, string controllerName)
{
Type controllerType = base.GetControll...