castle-windsor

Resolving dynamically base on name convention in Castle Windsor

时光毁灭记忆、已成空白 提交于 2019-12-21 20:23:07
问题 I have a seemingly simple use case. There is a ICsvReader component. Let's name it simply Reader here. We load a known set of CSV files and some of them have headers and some don't. Currently there are multiple readers: Reader_Skips1Row, Reader_Skips2Rows etc. Is there a way to register only one component and have Windsor look at the component key, strip the "_Skips..." part and resolve the required component with relevant properties set? I have tried subresolver and facility with no luck.

Recommended Castle Windsor/NHibernate stack?

試著忘記壹切 提交于 2019-12-21 20:05:08
问题 I've got a personal (learning) project that uses Castle Windsor (with the NHibernate facility) and NHibernate (and ASP.NET MVC and Moq, and SQL Server 2008, all stuff that I want to learn more about). I attempted to use NHibernate Validator over the weekend, but it needed the 2.1.0Alpha2 build of NHibernate. Since Castle Windsor 1.0RC3 is built against an older version of NHibernate, it all went wrong. I look on the Castle Windsor site, and the combined installer appears to be deprecated, and

Nhibernate, WinForms, Castle Windsor: Session Management

依然范特西╮ 提交于 2019-12-21 06:01:10
问题 I know the question of session management has been brought up in the past, but I could not find anything that helps me overcome my problem.. I have a number of repository classes (e.g CustomerRepository, ProductRepository etc.) which I resolve through Castle Windsor (Note: I am trying to apply the three calls pattern as outlined here). I figure I'd best have a session per Presenter (in my case, this is equivalent to one per form), however, the repository classes need to access the session for

Using Castle Windsor child containers to resolve a type with a specific instance

自闭症网瘾萝莉.ら 提交于 2019-12-21 05:41:15
问题 I'm currently using Castle Windsor's child container functionality to override the registration of a particular type with a specific instance in a factory method. I am using the child containers purely so that the registration is temporary for a single resolution - in other words, I don't want the registration to affect all resolutions for that type. Perhaps some code will explain what I mean. I have a Func which acts as a factory Func<IReportCategory, IReportCategoryViewModel> - I give it an

Castle Windsor/DelegatingHandler/IPrincipal Dependency Injection (DI)/Inversion of Control (IoC) in ASP.NET Web API

99封情书 提交于 2019-12-21 05:23:16
问题 I decided to clean this post up and I posted a sample project at ge.tt/3EwoZEd/v/0?c Spent around 30 hours on this already and still can't figure it out... help would be really appreciated! I have an ASP.NET Web API solution that uses this code: http://www.piotrwalat.net/basic-http-authentication-in-asp-net-web-api-using-message-handlers/ to implement "Basic HTTP authentication in ASP.NET Web API using Message Handlers". I'm new to IoC/DI and I'm trying to get this to work with Castle Windsor

Castle Windsor: How to test that all registered components are resolvable?

南笙酒味 提交于 2019-12-21 05:12:16
问题 I would like to write a test that just ensures that all components registered to my WindsorContainer can indeed be resolved. Anyone have any ideas how I can do that? 回答1: See these posts from Bil Simser: http://weblogs.asp.net/bsimser/archive/2008/06/04/the-first-spec-you-should-write-when-using-castle.aspx http://weblogs.asp.net/bsimser/archive/2008/06/27/testing-castle-windsor-mappings-part-deux.aspx 来源: https://stackoverflow.com/questions/731616/castle-windsor-how-to-test-that-all

Inject AutoMapper

百般思念 提交于 2019-12-21 01:17:47
问题 I have been working on injecting AutoMapper into controllers. I like the implementation of Code Camp Server. It creates a wrapper around AutoMapper's IMappingEngine. The dependency injection is done using StructureMap. But I need to use Castle Windsor for my project. So, how do we implement the following dependency injection and set-up using Windsor? I am not looking for line-by-line equivalent implementation in Castle Windsor. If you want to do that, please feel free. Instead, what is

Can I Use Typed Factory Facility to Return Implementation Based on (enum) Parameter?

会有一股神秘感。 提交于 2019-12-20 18:32:28
问题 Not sure if this is possible or not. I need to return the correct implementation of a service based on an enum value. So the hand-coded implementation would look something like: public enum MyEnum { One, Two } public class MyFactory { public ITypeIWantToCreate Create(MyEnum type) { switch (type) { case MyEnum.One return new TypeIWantToCreate1(); break; case MyEnum.Two return new TypeIWantToCreate2(); break; default: return null; } } } The implementations that are returned have additional

Failure to pass generic arguments with Castle Windsor

允我心安 提交于 2019-12-20 04:11:37
问题 There seems to be an issue with passing generic arguments when attempting to create a parametrized instance with Castle Windsor Demo of Failure to Pass Generic Arguments private static void Main(string[] args) { PassGenericParamAtResolutionTime(); Console.ReadLine(); } private static void PassGenericParamAtResolutionTime() { Console.WriteLine("Passing generic argument fails"); var container = new WindsorContainer(); container.Register(Component.For<ISandCoordinator<Simpleton>>()

Web API, odata v4 and Castle Windsor

喜夏-厌秋 提交于 2019-12-20 03:52:35
问题 I have WebApi project with ODataController and I'm trying to inject some dependency into MyController. I was following this blogpost by Mark Seemann. Consider code below. Problem is, that when is MyController creating, I got exception inside WindsorCompositionRoot Create method on this line, var controller = (IHttpController)this.container.Resolve(controllerType); An exception of type 'Castle.MicroKernel.ComponentNotFoundException' occurred in Castle.Windsor.dll but was not handled in user