castle-windsor

Overriding a component registration in Castle Windsor? Which container supports it?

跟風遠走 提交于 2020-01-15 05:22:31
问题 this is partially a duplication of the same question which has not been yet answered. See here: How can I override a component registered in Castle Windsor? Since I cannot comment or post any answers to an existing questions I created this question again in the hope that somebody knows the answer to a seemingly basic and simple question. Keep in mind that: I do not want to create a new container. I do not care if containers should not be used for Unit testing. I do not want to use derived

How can I inject an object into an WCF IErrorHandler implementation with Castle Windsor?

心不动则不痛 提交于 2020-01-14 13:31:31
问题 I'm developing a set of services using WCF. The application is doing dependency injection with Castle Windsor. I've added an IErrorHandler implementation that is added to services via an attribute. Everything is working thus far. The IErrorHandler object (of a class called FaultHandler is being applied properly and invoked. Now I'm adding logging. Castle Windsor is set up to inject the logger object (an instance of IOurLogger ). This is working. But when I try to add it to FaultHandler my

How can I use a string argument to case a namespace or type?

不羁的心 提交于 2020-01-14 07:24:11
问题 I need to get some JSON output in a .NET 2.0 C# script. The goal is to use one method to output all the JSON feeds I need. All the models have the same id and name properties so I have about 15 namespaces that have the same parts here. In short: since I'm use castle I can call the function like: /public/get_place_tags.castle /public/get_place_types.castle /public/get_place_whichEver.castle Which in castle is calling each method, ie: the get_place_tags(){} but I want to not have to work where

AOP Logging with StructureMap

被刻印的时光 ゝ 提交于 2020-01-14 03:26:06
问题 I am trying to implement simple logging with AOP approach with StructureMap. Basically, I want to do what is asked in the question Castle, AOP and Logging in .NET with StructureMap. CastleWindsor has the helpful IInterceptor that you can implement and then control when the a method is called with the IInvocation.Proceed() . Allowing you to perform logging before and after the call to the method is made. How can achieve this with StructureMap? I have tired using a custom Interceptor but the

How can I add a Dependency that can be used as type parameter 'TImpl' for Castle Windsor?

僤鯓⒐⒋嵵緔 提交于 2020-01-06 15:32:51
问题 I was getting this runtime exception with a particular URL: " Missing dependency. Component NRBQ.Web.Controllers.DeliveryController has a dependency on SeaStore.Data.Legacy.Interfaces.INRBQDeliveryRepository, which could not be resolved. Make sure the dependency is correctly registered in the container as a service, or provided as inline argument." ExceptionType: "Castle.MicroKernel.Resolvers.DependencyResolverException " ...so I added this code (based on existing code that works) to the IOC

Setting the name of a log4net logger

早过忘川 提交于 2020-01-06 07:22:27
问题 I am using the Castle logging facility with log4net in my application (MVC3 web app). However, rather than using the ILogger interface directly I have abstracted this by creating another interface (IAuditor) with a concrete implementation Log4NetAuditor (see code below). You may ask why I've done this since the point of ILogger is to abstract the underlying logging implementation. I've done because of strict observation of the onion architecture principle of abstracting all infrastructure

Castle Windsor Dependency Injection with Multiple Concrete Implementations

流过昼夜 提交于 2020-01-05 05:31:46
问题 Is there a method for Castle Windsor to inject multiple concrete implementations of a single interface into a constructor? I want to do something like this: class Some { public Some(IService[] services) { services.Each(s => s.DoSomething(this)); } } Note, at this level I do not have access to the IWindsorContainer and would like to keep it that way. 回答1: See http://hammett.castleproject.org/?p=257 来源: https://stackoverflow.com/questions/1473665/castle-windsor-dependency-injection-with

Castle Windsor - One class implementing multiple interfaces

我与影子孤独终老i 提交于 2020-01-05 05:29:20
问题 I register my two interfaces on application start as so:- container.Register(Component.For(typeof(IEntityIndexController)).ImplementedBy(typeof(SnippetController)).LifeStyle.Transient); container.Register(Component.For(typeof(ISnippetController)).ImplementedBy(typeof(SnippetController)).LifeStyle.Transient); Then when I try to run an IoC.Resolve on an object that uses the second interface here (ISnippetController) it throws the following exception:- Can't create component 'MyApp.Admin

Implementing IDataErrorInfo using Castle.DynamicProxy in lazy loading scenario using NHibernate

僤鯓⒐⒋嵵緔 提交于 2020-01-04 14:20:35
问题 I have implemented IDataErrorInfo interface using Castle.DynamicProxy IIterceptor. I have also implemented a NHibernate interceptor which instantiates my entities using this interceptor. The problem is with lazy loaded entities. These are constructed using a proxy factory class specified in nhibernate config file, which obviously does not provide IDataErrorInfo implementation. This proxies are masking the underlying implementation of IDataErrorInfo by my interceptor which causes the

Create components with circular relationships using Castle Windsor

折月煮酒 提交于 2020-01-04 05:16:49
问题 I'm implementing a finite-state machine, with each class representing a state. Each state knows which other states it can transition to, and this naturally leads to circular relationships. (See the State Design Pattern). For this simplified example I'm creating two components, where the first component has a reference to the second component, and the second component has a reference to the first. The problem is that the Windsor framework is correctly setting the references for the first