castle-windsor

Ordered resolution of types from Castle Windsor AllTypes

I have a group of classes that implement an interface for my application start-up activities. Here is the registration code: private static void ConfigureContainer() { var container = new WindsorContainer(); container.Register(AllTypes.Of<IStartupTask>() .FromAssembly(Assembly.GetExecutingAssembly())) ... ...

Windsor castle Injecting properties of constructed object

Some dependency injection containers enable you to inject configured services into an already constructed object. Can this be achieved using Windsor, whilst taking account of any service dependencies there may be on the target object? ...

Contextual Binding with Castle Windsor

Hi all Is it possible to get Windsor to return different implementations of a service based on a seperate parameter? For example, if I have a User object which has a Role property, I would like to be able to hydrate this object differently according the the value of Role. I would like to use an IUserService to do this, but have the con...

Dependency injection and physical paths in an ASP .NET environment - howto ?

I have a website that relies on dependency injection, using Castle Windsor. I need to use a component that needs to know the path to a file. I would like to specify the path in the configuration file as a virtual path relative to the web site root directory, so I would do this: <component id="configuration.documentLoader" type="SomeMo...

Castle Windsor: How do I register a factory method, when the underlying type isn't accessible to my assembly?

I have a project where my business layer is constructed using DI, but I'm trying to go an additional step and use Windsor to manage object construction. Let's just say I have a pre-existing data layer (that I don't want to modify), that can be accessed via the following interface: interface IDataFactory { IDataService Service { get;...

How does castle resolve singleton objects?

I have a singleton class which needs to be intialized by castle? I'm a little newbie in castle. I have looked for singleton in castle and I saw setting the lifestyle attribute of component to "Singleton" seems enough. But in that case it seems I don't need to implement the class in "Singleton Pattern". Just plain class definition for my ...

Using MVCContrib's WindsorControllerFactory with new Windsor Castle 2.0

I'm trying to use WindsorControllerFactory (the latest 1.0.0.916 version) together with the new Windsor Castle 2.0 (again, the latest version). But I'm getting the Could not load file or assembly 'Castle.Windsor, Version=1.0.3.0... error when starting the Web application. Anyway, during writing of this question I managed to pers...

Castle Windsor resolving and generics

Hi guys I have the following: public interface ISubject { ... } public class Subject<T> : ISubject { ... } public class MyCode<T> { ... pulic void MyMethod() { var item = container.Resolve<ISubject>(); //????? how do I pass in T } ... } In this case how do i do the resolve. Cheers Anthony ...

Will IoC lead to too many params for ASP.NET MVC Controller constructor?

I have decided to use ASP.NET MVC for a website project and want to follow some of the best practices being written about. So, I have separated out the Domain/Model into a separate project, created IRepositories and concrete repositories and have now turned my attention to Castle Windsor as the IoC. The problem I now face is that for a...

What are the differences between Castle Windsor 1.0 RC3 and Castle Windsor 2.0?

I've been reading a bunch and playing around with Castle Windsor 1.0 RC3 lately and really like the functionality it provides. Recently 2.0 was released but for the time being I'm pretty much stuck with RC3 for the next little while. So with that in mind what are some of the glaring differences between the two versions and what are some ...

Castle Windsor Fluent Registration - What does Pick() do?

When using auto-registration with castle windsor I see people doing things like _container.Register( AllTypes.Pick().FromAssembly(Assembly.GetExecutingAssembly()) .WithService.FirstInterface()); For the life of me I can't figure out what the Pick() method does nor can I find any documentation. Can anyone explain it to me? ...

Castle Logging Facility In 2.0 Release

Does anyone know if there are new binaries for the castle logging facility using the castle windsor 2.0 release? ...

Is it correct to have many Castle Windsor containers per application if those containers belong to different tiers?

I've been playing around with Castle Windsor lately and realized I could use it to back a container-like object I currently use already. So far I've only read information about an application having only one container instance per application. Is it correct to have many containers per application if those containers belong to different t...

Windsor Castle :- Inject Dictionary of Interfaces via configuration

Hi i am trying to inject a dictionary of interfaces but am getting an error from castle like this :- Castle.MicroKernel.SubSystems.Conversion.ConverterException: No converter registered to handle the type IFoo In order to go around the exception, I had to create a wrapper that contained a list of the Ifoo interface and returns it using...

Need help with Castle.Windsor as an Asp.Net MVC ControllerFactory please.

I'm trying to implement Steven Sanderson's WinsorControllerFactory from his pro Asp.Net MVC Framework book (great book, btw) and I'm stumbling into an issue. I'm not sure what else you'll need to know in order to formulate a response but I greatly appreciate any help in this. Thanks! Here's the code: WindsorControllerFactory public cl...

interface<T> binding in Castle Windsor

Hi all. I have a common datacontainer interface IDataContainer I use it for different types of T IPerson, ISuperMan etc In castle i regsiter it with container.AddComponentWithLifestyle<IDataContainer<IPerson>, DataContainer<Person>>(LifestyleType.Transient); container.AddComponentWithLifestyle<IDataContainer<ISuperMan>, DataContain...

Castle Windsor Ioc Resolving Generic classes in the web.config

I have an interface declared as IRetrievable<T, idT> where T is the retrieved type and IdT is the argument passed. How do I configure the castle windsor IoC container to resolve that to a specfic Implementation. Such as a class defined as FooRetriever : IRetrievable<Foo, string> I found an example that showed how to resolve a sing...

Dependecy Injection and Class Inheritance

I feel like this is something I should already know, but I'm just not firing on all engines today... I have a base class with a single ctor that takes an implementation of an interface as it's only parameter. I'm using a DI framework and have my component registrations all set up and working fine. When I inherit from this base class, ...

Inject a MembershipProvider into ASP.Net MVC AccountController

Asp.Net MVC 1.0 project templates include an AccountController class, which supports constructor injection: public AccountController(IFormsAuthentication formsAuth, IMembershipService service) { FormsAuth = formsAuth ?? new FormsAuthenticationService(); MembershipService = service ?? new AccountMembershipService(); } An A...

Specifying instance for registration of a component with Castle Windsor

Hi, I have what is probably a simple question here about Castle Windsor, which I haven't been using for very long. I'm trying to register a service with a specific instance that will be the singleton implementation of the service. The container cannot try to create the implementation of the service itself because it has dependencies tha...