castle-windsor

IoC Castle Windsor in MVC routing problem

冷暖自知 提交于 2019-12-07 18:48:18
问题 I've set up castle windsor in my mvc app. everything works great except it also catches routes that are of type link or image. The problem is that right before exiting from the controller and generating the view "GetControllerInstance" is executed with 'null' type. This happends anytime there a link on a page like: <link rel="stylesheet" type="text/css" href="non-existing.css"/> Or a link to an image that does not exist. Why is this happening? My windows class: public class

is there something like @predestroy in the spring as in the castle windsor

两盒软妹~` 提交于 2019-12-07 17:35:34
问题 Anything like @PreDestroy in the spring-framework? 回答1: If you define a bean that implements the DisposableBean interface then Spring will call the void destroy() throws Exception; method before destrying the bean. That's one way, the other is when your bean doesn't have to implement the given interface. In one of yours ConfigurationSupport classes your bean has to be defined as as pulic method with the @Bean annotation. @Bean (destroyMethod="yourDestroyMethod") public YourBean yourBean() {

How can I override a component registered in Castle Windsor?

徘徊边缘 提交于 2019-12-07 14:12:11
问题 I'm just starting with Windsor, so please be gentle :) I have a scenario where I want to be able to override/replace components placed inside a windsor container. Read on ... In my prod code, I want to be able to register a component which implements a base class, and use a container to resolve the implementer. So far, using container.Register(Component.For<LoggerBase>().ImplementedBy<DebugLogger>()); and container.Resolve<LoggerBase>(); In my tests, I'd like to add a stub/mock implementation

configure Castle Windosor and generic

北城以北 提交于 2019-12-07 13:53:30
问题 this is my code in Global.asax WindsorContainer container = new WindsorContainer(); container.Register(Component.For(typeof(IRepository<>)) .ImplementedBy(typeof(NHRepository<>)) .LifeStyle.Transient) I've tried to translate it in a xml config file with this but didn't work <component id="NHRepository" service="NCommon.Data.IRepository'1, NCommon" type="NCommon.Data.NHibernate.NHRepository'1, NCommon.NHibernate" lifestyle="transient"> </component> How can I convert this code in a config file

Is this a good solution to handle NHibernate Isession as PerWebRequest

淺唱寂寞╮ 提交于 2019-12-07 12:49:58
问题 I Have been struggeling with NHibernate session management and have now ended up with two possible solutions to meet a session per web request. I'm using Windsor for IoC in an ASPNET mvc project First solution is to open a session in begin_request and close/dispose it again in end_request. In Windsor setup I would have container.Register(Component.For().UsingFactoryMethod(() => SessionFactory.GetCurrentSession()).LifeStyle.Transient; This solution creates the session per request and shares it

Registering generic decorators in Windsor [duplicate]

独自空忆成欢 提交于 2019-12-07 09:01:15
问题 This question already has answers here : How can I register a generic decorator using Castle Windsor? (2 answers) Closed 3 years ago . I have an interface that looks like this: public interface IQueryHandler<in TQuery, out TResult> where TQuery : IQuery<TResult> { TResult Handle(TQuery query); } I want to wrap all my handlers with this caching decorator: public class CachingQueryHandler<TQuery, TResult> : IQueryHandler<TQuery, TResult> where TQuery : IQuery<TResult> { public

Castle Windsor: Best way to log when a component is registered?

霸气de小男生 提交于 2019-12-07 06:51:55
问题 I would like to log when a component (interface and implementation) is registered to my container. What is the best way of doing this? I found the IKernelEvents interface that looks promising but I can't find how to actually use it. 回答1: Nevermind, found that IKernel implements IKernelEvents Therefore simply WindsorContainer.Kernel.ComponentRegistered += (k, h) => _logger.Debug("Registered {0} - {1}/{2}", k, h.ComponentModel.Service.FullName, h.ComponentModel.Implementation.FullName); 来源:

Umbraco MVC with Castle Windsor

空扰寡人 提交于 2019-12-07 05:37:18
问题 Does anyone have any example code for getting Umbraco MVC working with the Castle Windsor dependency injection framework? The problem I'm having is getting my surface controllers to use injectable parametised constructors. I know I'm doing something wrong but not sure what. I have followed the (non-Umbraco) tutorial here - http://docs.castleproject.org/Windsor.Windsor-tutorial-part-four-putting-it-all-together.ashx - which basically means on App_Start I'm running this code: var container =

ravendb, castle IoC ,Wcf facility - doc session liefstyle

陌路散爱 提交于 2019-12-07 05:26:59
问题 What's the recommended lifestyle for raven doc session and store under a windsor ioc, wcf facility setup hosted in IIS? I keep seeing this error: Error TempPathInUse (JET_errTempPathInUse, Temp path already used by another database instance)` here is my setup: public class RavenInstaller : IWindsorInstaller { public void Install(IWindsorContainer container, IConfigurationStore store) { container.Register( Component.For<IDocumentStore>().ImplementedBy<DocumentStore>() .DependsOn(new {

Architecture problem: use of dependency injection resulting in rubbish API

家住魔仙堡 提交于 2019-12-07 05:25:38
问题 I'm tring to create a class which does all sorts of low-level database-related actions but presents a really simple interface to the UI layer. This class represents a bunch of data all within a particular aggregate root, retrieved by a single ID int. The constructor takes four parameters: public AssetRegister(int caseNumber, ILawbaseAssetRepository lawbaseAssetRepository, IAssetChecklistKctcPartRepository assetChecklistKctcPartRepository, User user) { _caseNumber = caseNumber;