castle-windsor

Where & How Castle Windsor sets up logging facility

青春壹個敷衍的年華 提交于 2019-11-30 04:09:33
I'm fairly new to Castle Windsor and am looking into the in's and out's of the logging facility. It seems fairly impressive but the only thing i can't work out is where Windsor sets the Logger property on my classes. As in the following code will set Logger to the nullLogger if the class hasn't been setup yet but when Resolve is finished running the Logger property is set. private ILogger logger; public ILogger Logger { get { if (logger == null) logger = NullLogger.Instance; return logger; } set { logger = value; } } So what I am wondering is how and where windsor sets my Logger property.

Multiple Interface injection with castle windsor

别等时光非礼了梦想. 提交于 2019-11-30 04:01:21
How can you get castle Windsor to choose the right implantation of a interface at run time when you have multiple implementations in the container. For example lets say i have a simple interface called IExamCalc that does calculations to work out how someone did in that exam. No we have several implementation of this like bellow for example, public interface IExamCalc { int CalculateMark(ExamAnswers examAnswers) } public class WritenExam : IExamCalc { public int CalculateMark(ExamAnswers examAnswers) { return 4; } } public class OralExam : IExamCalc { public int CalculateMark(ExamAnswers

Castle Windsor: How do I inject all implementations of interface into a ctor?

試著忘記壹切 提交于 2019-11-30 03:02:33
I've written an interface which is implemented by multiple classes. I want to write a Service class which will have all the registered implementations injected into its ctor. The only solution I can think of is to call the Service Locator within the ctor and ask it to Resolve() all implementations. Ideally I would like something like this - interface IVehicle { void Start(); } class Car : IVehicle { public void Start() { Console.WriteLine("Car started."); } } class Truck : IVehicle { public void Start() { Console.WriteLine("Truck started."); } } class Motorbike : IVehicle { public void Start()

Looks like you forgot to register the http module with Windsor Castle with IIS7

徘徊边缘 提交于 2019-11-30 02:58:57
I am using windsor DI framework in one of my MVC project. The project works fine when I tried to run from Visual Studio 2008. But when i tried to run the project creating an application in IIS7 then I recieved the following error message: Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule Add '<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.MicroKernel" />' to the section on your web.config But this module already exists in the httpmodule section of web.config file. Does anyone know

How can I unit test my controller to make sure Windsor can resolve dependencies when using PerWebRequestLifestyle

感情迁移 提交于 2019-11-30 01:17:55
问题 I have the following unit test in my application: [TestMethod] public void Windsor_Can_Resolve_HomeController_Dependencies() { // Setup WindsorContainer container = new WindsorContainer(); container.Install(FromAssembly.Containing<HomeController>()); // Act container.Kernel.Resolve(typeof(HomeController)); } The point of this is to make sure I don't have any windsor configuration issues that I won't realize until I access an action on that controller. The problem is that all my object

How do I tell Windsor to add an Interceptor to all components registered that implement IMustBeIntercepted

不问归期 提交于 2019-11-29 22:13:22
问题 If I registered several components with Windsor. IAnimal provides BigAnimal IPerson provides SmellyPerson IWhale provides BlueWhale etc.. pretty standard component registeration all the above types implement IMustBeIntercepted, how do I tell the container add an interceptor to all types that implement IMustBeImplemented so that when Resolve is called it is returned a BigAnimal with an interceptor as defined since it matches. I know I can do this for each one but its extra XML config or

Castle Windsor are there any downsides?

回眸只為那壹抹淺笑 提交于 2019-11-29 21:21:31
I have been looking into the Castle project and specifically Windsor. I have been so impressed with what is possible with this technology and the benefits of having a such a loosely coupled system are definitely apparent. The only thing I am unsure of is if using this method has any downsides, specifically in asp.net? for example performance hits, etc. I am trying to make the benefits of this approach visible to my fellow developers here and am being hit with the following comebacks: That is using reflection and each time that an object is called from the container, reflection must used so

Dependency Injection in WebAPI with Castle Windsor

孤街醉人 提交于 2019-11-29 20:43:13
I want to implement Dependency Injection in WebApi application using Castle Windsor. I have following sample code - Interface - public interface IWatch { { DateTime GetTime(); } } Following Watch class implements IWatch Interface - public class Watch:IWatch { public DateTime GetTime() { return DateTime.Now; } } WebApi Controller - WatchController as below - public class WatchController : ApiController { private readonly IWatch _watch; public WatchController() { _watch = new Watch(); } //http://localhost:48036/api/Watch public string Get() { var message = string.Format("The current time on the

Difference between IWindsorInstaller and AbstractFacility in Castle

时光怂恿深爱的人放手 提交于 2019-11-29 18:28:40
问题 I've always been using facilities to register my components but noticed the IWindsorInstaller. It both look similar to me and I would like to know what the difference is between both and which one should be used where. 回答1: Dan, the difference is the following: installers are meant to encapsulate discrete units of registration. In other words you use installers to register application components in the container. There are helpers for that like Configuration class, or FromAssembly class that

How can I tell the Web API / Castle Windsor routing engine to use a different database instance in my Repository?

笑着哭i 提交于 2019-11-29 17:25:11
My understanding of the flow of events with an ASP.NET Web API Castle Windsorized app that uses Models, Repositories, and Controllers: 0) The client calls a REST method via a URI such as: http://localhost:28642/api/platypi/Count 1) Castle Windsor's routing engine maps intercepts that incoming call, sending the registered concrete class that implements the interface platypiController has as an arg in its constructor. 2) That constructor determines which of its methods is to be called (what corresponds to "Count" in this case). 3) That Controller method calls a corresponding method on the