castle-windsor

Castle Windsor & Command Pattern

醉酒当歌 提交于 2019-12-11 03:17:40
问题 I am trying to implement a Command, CommandHandler and CommandDispatcher pattern using Castle Windsor without manually asking the container to resolve a CommandHandler based on Command type (which is generally considered an anti-pattern). I found this old article, but the implementation of ITypedFactoryComponentSelector has changed, so now it returns a Func, instead of TypedFactoryComponent . Anyway, I would really appreciate if someone can shed some light on the "correct" implementation of

How to instantiate a class based on web.config file with Castle Windsor?

谁说胖子不能爱 提交于 2019-12-11 03:17:09
问题 I'm working on an ASP.NET MVC application and I would like to instantiate a class based on settings written in web.config. <configSections> <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" /> </configSections> <castle> <components> <component id="SqlRepository" service="GomokuGameAppDomain.IGameRepository, GomokuGameAppDomain" type="GomokuGameAppDomain.SqlGameRepository, GomokuGameAppDomain" lifestyle="PerWebRequest"> <parameters>

Is there a way to explicitly register open generic decorators with castle windsor

扶醉桌前 提交于 2019-12-11 03:13:39
问题 I use castle windsor a lot in a project i'm working on and use decorators a little so I might have something like this in my installer Component.For<IMyViewModelService>().ImplementedBy<MyViewModelServiceCacheDecorator>().LifestyleTransient() Component.For<IMyViewModelService>().ImplementedBy<MyViewModelService>().LifestyleTransient() So doing this is easy enough and works well. I started reading around the simple injector framework and I really like they way you can specifically set the

How do I register classes by both interface and namespace with Windsor?

可紊 提交于 2019-12-11 02:48:56
问题 I'm trying to use Castle.Windsor (3.2.0.0) convention based registration, but can't seem to figure out how to register classes implementing a particular interface only in a particular namespace. e.g. what I really want to be able to write is something like this : container.Register(Classes.FromThisAssembly() .InNamespace("MyApp.EventHandlers") .BasedOn(typeof(IHandlesEvent<>)) .WithServiceAllInterfaces() But I get a warning that seems to imply what this will really do is register everything

At what point in a Web API app can I intercept the URI arguments and route the calls accordingly?

时间秒杀一切 提交于 2019-12-11 02:27:28
问题 Note: This question is indeed somewhat similar to this one, but I think I can put it in a simpler and more specific way. I'm using Castle Windsor to intercept the URI passed to my Web API app to register the appropriate concrete class to the Controller's constructor. What I want to be able to do is pass a "site number" on the URI, perhaps always as either the first or last arg. IOW, for site 42, instead of http://localhost:28642/api/platypi/GetAll ...it would be: http://localhost:28642/api

How to prevent Castle Windsor from injecting property dependencies?

别来无恙 提交于 2019-12-11 02:13:31
问题 Is there a way to prevent Castle Windsor from automatically injecting dependencies into properties (besides the [DoNotWire] attribute)? 回答1: Duplicate: Windsor Container: How to specify a public property should not be filled by the container? See also: http://groups.google.com/group/castle-project-users/browse_thread/thread/f1ec737ff243c19d http://jfromaniello.blogspot.com/2009/07/noninjectable-service.html http://using.castleproject.org/display/Contrib/Castle.Facilities

Log4Net with castle windsor

青春壹個敷衍的年華 提交于 2019-12-11 01:46:24
问题 I am configuring logging for my application and for logging I am using log4net and castle windsor for DI. I want logging framework to be wrap inside custom implementation so it can be changed in future. public interface ICustomLogger { void Debug(object message, Exception ex = null); void Info(object message, Exception ex = null); void Warn(object message, Exception ex = null); void Error(object message, Exception ex = null); void Fatal(object message, Exception ex = null); } public class

Castle Windsor 3 + Fluent NHibernate + Castle.NHibernate.Integration

蹲街弑〆低调 提交于 2019-12-11 01:39:19
问题 I have created a sample project to replicate an issue I'm having with Castle Windsor and the NHibernate Integration Facility. I get the following exception: Method not found: 'Void Castle.Core.DependencyModel..ctor(Castle.Core.DependencyType, System.String, System.Type, Boolean)'. With the following stack-trace: at Castle.Facilities.NHibernateIntegration.Internal.NHSessionComponentInspector.ProcessModel(IKernel kernel, ComponentModel model) at Castle.MicroKernel.ModelBuilder

Why can Windsor only intercept virtual or interfaced methods?

青春壹個敷衍的年華 提交于 2019-12-11 00:54:09
问题 I'm reading the documentation and see that if you don't use an interface then Windsor can only intercept virtual methods? Is this a limitation with Windsor or simply the C# language? I'm looking for an in depth answer. 回答1: The C# language is completely irrelevant here. The question is how the interception works at the runtime level. One technique is inheriting from the class/implementing the interface and using that as a proxy. This can obviously only override virtual methods and interface

Castle Windsor - Resolving a generic implementation to a base type

十年热恋 提交于 2019-12-10 23:58:17
问题 I'm trying to use Windsor as a factory to provide specification implementations based on subtypes of XAbstractBase (an abstract message base class in my case). I have code like the following: public abstract class XAbstractBase { } public class YImplementation : XAbstractBase { } public class ZImplementation : XAbstractBase { } public interface ISpecification<T> where T : XAbstractBase { bool PredicateLogic(); } public class DefaultSpecificationImplementation : ISpecification<XAbstractBase> {