castle-windsor

Inject ASP.NET MVC Controller property into service layer dependency?

I am using an approach similar to the one in this ASP.NET MVC tutorial where you pass a wrapper around a controller's ModelState collection into a validation class so that the controller can access error information. Here is a cooked up example: interface IProductValidator { void Validate(Product item); } class ProductValidator { ...

Castle Windsor Registration of Interface and Abstract Implementations

I am trying to work out how to auto register implementations of an generic abstract class or interface. Here are my classes: public abstract class AbstractValidator<T> : IValidator<T> { public void Validate(T) { ... } } public class CustomerValidator:AbstractValidator<Customer> { ... } I am trying the following: _co...

Regarding passing of config parameters at runtime to container.resolve(string key,Idictionary args)

Hi, I have a console application that is using a wrappers class to override the Resolve method of the windsor container. I have registered my services in the app.config file of the calling class. I have a service that requires some parameters to be passed through config file. This functionality is working fine till now. My requirement is...

Castle DynamicProxy Interface Proxy Generation

I have a WindsorContainer. I have a ILazyComponentLoader (if it matters) and an Interface (ISomething) with an Interceptor attribute on in. [Interceptor(typeof(DynamicImplementationInterceptor)] public interface ISomething I want Windsor to use ProxyGenerator.CreateInterfaceProxyWithoutTarget when resolving the interface via contai...

Cannot Get RazorView from Windsor Container using MVC 3 Beta

Hi, This is how my Application_Start looks: protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); _container.Register(Component.For<IWindsorContainer>() .Instance(_container), ...

Castle Windsor IOC: Passing constructor parameters to child components

Hello, The following code is for demo purposes only. Lets say i have 2 components (businessService, and dataService), and a UI class. UI class needs a business service, businessService needs a dataService, and dataService relies on a connectionString. Form the UI class i need to resolve the business service, so i am writing the belo...

How do I use Windsor Container in a different assembly but same application?

From what I understand about Windsor Container and MVC applications, is that there should only be one instance of the container and it's usually registered in Global.asax for the running life of the application. I've separated out my business layer in to a separate assembly from the web application and obviously I can't get to that inst...

WCF Dependency Injection using Castle Windsor - Please help ??

I have a WCF service which calls the business component which calls the repository and I have got it end to end working using Castle Windsor using it's WCF Facility. The WCF Facility registration and rest of the component registration happens in the Global.asax file like this. public class Global : System.Web.HttpApplication ...

Windsor 2.5 does not work in Medium Trust

I'm busy upgrading my MVC site to MVC 3, Windsor 2.5.1, NHibernate 3.0 Beta1. And all previous versions worked fine. But I am hitting a wall with Windsor: [TypeLoadException: Inheritance security rules violated while overriding member: 'Castle.MicroKernel.DefaultKernel.InitializeLifetimeService()'. Security accessibility of the overridi...

Looking for books on IoC

Hi, I'm having a hard time finding books (eBook or hard copy) on any dependency injection frameworks. I'd really love one on Ninject but I can't seem to find any, not even for the popular Windsor Castle. ...

How can i get all registered services in Castle.Windsor

Is there any way to get all registered service type and implementation type in windsor container ...

NUnit integration tests and dependency injection

I'm currently making use of Castle Windsor version 2.1 as my container and would like to perform integration tests using the services registered with it. Currently, I do this my using the Common Service Locator to retrieve my service instance and perform my integration tests against it as such: var myService = ServiceLocator.Current.Ge...

Solving a dependency graph for aspect oriented component

public interface IFoo : ICanCatch, ICanLog { void Bar () } public class Foo : IFoo { public void Bar () { Console.WriteLine ("Bar"); } } IWindsorContainer _Container; [TestFixtureSetUp] public void init () { _Container = new WindsorContainer(); _Container.Register( Component.For<LogInterceptor> (),...

castle windsor register a generic interface and retrieve all registered instances the inherit indirectly from it

I have the following structure - public interface IBaseInterface<T> { } public interface IChildInterface1<Class1> : IBaseInterface<Class1> { } public interface IChildInterface2<Class2> : IBaseInterface<Class2> { } public class ImplementationClass1 : IChildInterface1<Class1> { } public class ImplementationClass2 : IChildInterface2<Cl...

Castle Windsor DynamicProxy Interception IInvocation Documentation

On a Castle Castle.DynamicProxy.IInvocation, what's the difference between GetConcreteMethod GetConcreteMethodInvocationTarget Method I read the documentation, but I don't understand the difference, especially between the first two. I'm guessing that Method is just the MethodInfo for the method on the actual registered type? ...

Castle.Windsor: Resolving Type with empty protected constructor

Hi everyone, I'm using NHibernate + Castle.Windsor to add some behaviour to my entities. This means that NHibernate creates entities through Windsor. This means that I must have a default empty constructor so Windsor will be able to instantiate my entities. I don't like this for many reasons, the main one being that I dislike to have ob...

Setter injection on an existing service instance in Castle Windsor

Does Castle Windsor support applying setter injection to existing service instances? I have a case in which I have no control over the creation of certain class instances while I do need to resolve dependencies for them. This rules out constructor injection but leaves the door open for setter injection since I can intercept the new insta...

How to reuse a transient dependency in same context with Castle Windsor DI container

If I have the following setup, how can I configure my container to use the same database, when objects are created in the same context public class Database { } public interface IRepository { Database Database { get; } } public interface IFooRepository : IRepository { } public interface IBarRepository : IRepository { } public class Foo...

Castle Windsor: Typed Factory not using registered sub resolver

I have created simple factory: public interface ICommandFactory { ICommand CreateCommand(string componentName); } Implemented using Typed Factory feature from Windsor: Container.AddFacility<TypedFactoryFacility>(); Container.Kernel.Register(Component.For<ICommandFactory>().AsFactory()); also i am using subresolver: Container.K...

Castle Windsor : Possible bug with Startable Facility and "decorator pattern" dependencies

When attempting to register a startable component that depends on a service whose implementation "decorates" the same service interface, Castle fails to resolve the startable component, claiming that the dependency cannot be resolved. Curiously enough, explicitly resolving the startable component works as expected. I have seen this beh...