castle-windsor

IOC on IValidationDictionary with Castle Windsor

白昼怎懂夜的黑 提交于 2019-12-20 02:58:26
问题 I'm new to Castle Windsor and am just using the latest version. I've created entries for my repositories which are working fine but I have one final dependency that I'm passing into my controller. I've created a ModelStateWrapper which inherits from IValidationDictionary. The ModelStateWrapper takes a ModelStateDictionary in it's constructor so that in my code I can pass the following as an example: IMembershipService _memSvc; IValidationDictionary _validationService; public AccountController

Windsor Castle :- Inject Dictionary of Interfaces via configuration

我是研究僧i 提交于 2019-12-20 02:34:20
问题 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 a property. The wrapper was then used in the configuration ==> dictionary instead of dictionary Is there a way in castle that I can just have a dictionary of

Castle Windsor: Register class with internal constructor?

旧城冷巷雨未停 提交于 2019-12-20 01:46:35
问题 A Castle Windsor question: Is it possible to register a class that has an internal constructor with the container? Thanks Joni 回答1: Yes, it is possible. Default component activator looks only for public constructors. You can either provide custom component activator for that component that would take internal constructor into account, or use for example factory to activate the component: var container = new WindsorContainer() .AddFacility<FactorySupportFacility>() .Register( Component.For<Foo

castle PerRequestLifestyle not recognize

筅森魡賤 提交于 2019-12-19 08:23:19
问题 New to Castle/Windsor, please bear with me. I am currently using the framework System.Web.Mvc.Extensibility and in its start up code, it registered HttpContextBase like the following: container.Register(Component.For<HttpContextBase>().LifeStyle.Transient.UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current))); What I wanted to do is to change the behavior and change the lifestyle of httpContextBase to be PerWebRequest. so I have change the code to the following: container

Setting up Inversion of Control (IoC) in ASP.NET MVC with Castle Windsor

好久不见. 提交于 2019-12-19 05:58:53
问题 I'm going over Sanderson's Pro ASP.NET MVC Framework and in Chapter 4 he discusses Creating a Custom Controller Factory and it seems that the original method, AddComponentLifeStyle or AddComponentWithLifeStyle , used to register controllers is deprecated now: public class WindsorControllerFactory : DefaultControllerFactory { IWindsorContainer container; public WindsorControllerFactory() { container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle"))); // register all the

Castle Windsor: Using convention registration along with specific implementations

百般思念 提交于 2019-12-19 03:25:11
问题 Assume we have IFoo implemented by Foo and IBar implemented by FirstBar and SecondBar. Using this convention registration: container.Register( AllTypes.FromThisAssembly().Pick() .WithService.DefaultInterface()) We'll have three entries in the container: IFoo = Foo IBar = FirstBar IBar = SecondBar Now, how can we tweak this registration to be able to tell the container that for IBar we want SecondBar registered only? Sort of: container.Register( AllTypes.FromThisAssembly().Pick() .WithService

Dynamic selection of interface implementation using IoC

时间秒杀一切 提交于 2019-12-19 03:13:24
问题 I have a situation where the implementation of an interface is determined at runtime. For example, I check a string and then determine which subclass to use, without IoC it looks like the following: if (fruitStr == "Apple") { new AppleImpl().SomeMethod(); } else { new BananaImpl().SomeMethod(); } Both classes AppleImpl and BananaImpl are implementation of the same interface, say IFruit . How can this be done using IoC/Dependency Injection, especially in Castle Windsor ? 回答1: This is the

Can't create component as it has dependencies to be satisfied

自古美人都是妖i 提交于 2019-12-18 15:53:41
问题 I am learning DDD, n-Tier, Repositoriess and the likes. Someone pointed me to ASP.NET Boilerplate and I decided to start a test project using that. I have never dealt with dependency injection so this is all new to me, but the DI dependency it uses ius Castle Windsor. Now, I created a Model and from this Model I created an interface. I also added a Service. Whenever I fire up the app it gives me this error: Can't create component 'TestApp.Services.MemberInfo.MemberAppService' as it has

Windsor Container: How to specify a public property should not be filled by the container?

馋奶兔 提交于 2019-12-18 14:58:09
问题 When Instantiating a class, Windsor by default treats all public properties of the class as optional dependencies and tries to satisfy them. In my case, this creates a rather complicated circular dependency which causes my application to hang. How can I explicitly tell Castle Windsor that it should not be trying to satisfy a public property? I assume there must be an attribute to that extent. I can't find it however so please let me know the appropriate namespace/assembly. If there is any way

Using Castle Windsor WcfFacility to create client endpoints

 ̄綄美尐妖づ 提交于 2019-12-18 13:25:44
问题 I have created three assemblies. A web site, a WCF service and a contracts assembly that holds the interfaces that the services implement. I would like to use Castle Windsor to create the services for me on the client (website) so that I do not have to have an endpoint in the web.config of the web site for each service that I wish to use. I would like to look at the contract assembly and get all the service interfaces in a namespace. Right now for every service I have something like the