castle-windsor

Testing Castle windsor Component with PerWebRequest lifestyle

我怕爱的太早我们不能终老 提交于 2019-12-18 12:58:09
问题 I'm trying to do some testing with castle windsor involved, in one of my tests I want to check the windsor installers, so I check that the container can resolve my components given its interface. So far, so good, the problem starts when the component has PerWebRequest lifestyle in its installer, at first it complained about HttpContext.Current is null, having that one solved creating a fake Context in test setup I'm now having this exception in nunit test System.Exception : Looks like you

Where & How Castle Windsor sets up logging facility

筅森魡賤 提交于 2019-12-18 11:13:49
问题 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; }

Implementing UnitOfWork with Castle.Windsor

纵然是瞬间 提交于 2019-12-18 10:46:15
问题 Simple question. How do I use UnitOfWork with Castle.Windsor, nHibernate, and ASP.NET MVC? Now for the extended details. In my quest to understand the UnitOfWork pattern, I'm having difficulty coming across anything that uses a direct example in conjunction with Castle.Windsor , specifically in regards to the way it needs to be installed. Here is my understanding so far. IUnitOfWork The IUnitOfWork interface is used to declare the pattern The UnitOfWork class must Commit and Rollback

Register component based on parameter name on requestor in windsor

半世苍凉 提交于 2019-12-18 08:39:28
问题 I have this interface for using AutoMapper: public interface IMapper { object Map(object source, Type sourceType, Type destinationType); } Then for each type of data, I have a different mapper class , for example: public class UserMapper : IMapper { static UserMapper() { Mapper.CreateMap<User, UserViewModel>(); Mapper.CreateMap<UserViewModel, User>(); } public object Map(object source, Type sourceType, Type destinationType) { return Mapper.Map(source, sourceType, destinationType); } } Then I

Using Castle.Windsor with Windows Forms Applications

最后都变了- 提交于 2019-12-18 07:07:17
问题 Up until this point, I have been learning IoC/DI with Castle.Windsor using ASP.NET MVC, but I have a side project that is being done in Windows Forms, and I was wondering if there is an effective way to use it for that. My problem is in the creation of forms, services, etc. In ASP.NET MVC, there is a sort of 'Activator' that does this under the hood, but this isn't the case in Windows Forms. I have to create a new Form like var form = new fclsMain(); , so a Form like .. class fclsMain :

Injecting a primitive property in a base class with Castle Windsor

放肆的年华 提交于 2019-12-18 07:04:38
问题 I have got the following interface definition: public interface ICommandHandler { ILogger Logger { get; set; } bool SendAsync { get; set; } } I have multiple implementations that implement ICommandHandler and need to be resolved. While Castle Windows automatically injects the Logger property, when an ILogger is injected, I can't find a way to configure the SendAsync property to be set to true by Windsor during the creation of new instances. UPDATE The command handlers implement a generic

Carrying per-request context using the HttpRequestMessage.Properties

寵の児 提交于 2019-12-18 06:14:22
问题 In a Web API application, I use Castle Windsor to supply services configured with PerWebRequest lifetime and everything works fine on IIS. However, when I use the ASP.NET Web API Self Host (Beta) package I need to create a custom lifetime in order to scope those services per HTTP request. How can I carry per-request context using the HttpRequestMessage.Properties? 回答1: I'd suggest you using a message handler to set some your object into HttpRequestMessage.Property: public class MyApplication

Applying Aspect Oriented Programming

让人想犯罪 __ 提交于 2019-12-18 04:37:28
问题 I've been using some basic AOP style solutions for cross-cutting concerns like security, logging, validation, etc. My solution has revolved around Castle Windsor and DynamicProxy because I can apply everything using a Boo based DSL and keep my code clean of Attributes. I was told at the weekend to have a look at PostSharp as it's supposed to be a "better" solution. I've had a quick look at PostSharp, but I've been put off by the Attribute usage. Has anyone tried both solutions and would care

Castle Windsor strange behaviour wth property injection and factory method

Deadly 提交于 2019-12-18 04:13:06
问题 I am using Castle Windsor 2.5.1 in an ASP.NET MVC project and using property injection to create an object which I expect to always be available on a base controller class. I am using a factory to create this object, however if there is an error in the constructor, I do not get a warning from Windsor at all and it just returns my object but without injecting the property. Is this the expected behaviour, and if so, how can I get an error raised when a factory fails to return anything? Here is

What are “ForwardedTypes” in the context of Castle Windsor component registration?

自闭症网瘾萝莉.ら 提交于 2019-12-18 03:17:15
问题 As the subject says, really! What do they do? 回答1: Forwarded types allow you to have more than one service implemented by a single implementation, for a concrete example say we have two interfaces for working with tree nodes of some sort: public interface INodeAlterationProvider { ... } public interface IChildNodeListProvider { ... } And various components take a dependency on one or both of those interfaces. However in implementing each of those interfaces you discover that their is a lot of