castle-windsor

Windsor Setter Injection in code

江枫思渺然 提交于 2019-12-10 20:31:59
问题 I'm using Windsor to do IoC in our .Net project, but I'm having difficulties doing setter injection in code. I believe it comes from the fact that I blanket register my components, since eventually I'm hoping that legacy project will be fully IoC compliant and mostly Unit Tested (sweet dreams!). Here is how I'm registering the DAOs: container .Register(AllTypes.FromAssemblyNamed("MyApp.Business") .Where(Component.IsInNamespace("MyApp.Business.Dao")) .WithService.DefaultInterface()); And here

Castle Windsor proxies, implicit interfaces and WPF Binding

不羁的心 提交于 2019-12-10 20:11:49
问题 I am attempting to implement a WPF ViewModel using Castle Windsor Dynamic Proxies. The idea is that I want to supply an interface (IPerson below should suffice as an example), a concrete backing class, and an interceptor (for providing automatic implementation of INotifyPropertyChanged). The interceptor implementation is here: http://www.hightech.ir/SeeSharp/Best-Implementation-Of-INotifyPropertyChange-Ever The problem that I am seeing is that when I bind my models to WPF controls, the

Castle Windsor: How to register internal implementations

Deadly 提交于 2019-12-10 19:33:40
问题 This registration works when all the implementations of IService are public: AllTypes .Of<IService>() .FromAssembly(GetType().Assembly) .WithService.FirstInterface() For example: public interface IService {} public interface ISomeService : IService {} public class SomeService : ISomeService {} Resolving ISomeService returns an instance of SomeService. But if the SomeService class is internal, the container throws an exception that states that ISomeService is not registered. So is there any

Using castle windsor with interceptors and asp.net

此生再无相见时 提交于 2019-12-10 19:08:14
问题 I'm trying to add logging with aspect orientated programming using castle windsor in plain asp.net, i.e. not MVC I've added a class that implements the IInterceptor interface and an attribute that inherits from Attribute. public class LogAttribute : Attribute { public Level LogLevel { get; set; } public LogAttribute(Level level) { LogLevel = level; } } public class LoggingInterceptor : IInterceptor { public void Intercept(IInvocation invocation) { MethodInfo mi = invocation.Method;

Castle windsor lifestyle issue

纵饮孤独 提交于 2019-12-10 18:21:17
问题 I am implementing hangFire which is a job scheduling library in my project. I am facing the same issue as faced in this link However after replacing LifestylePerWebRequest() with HybridPerWebRequestTransient() I am still getting the same error message: HttpContext.Current is null. PerWebRequestLifestyle can only be used in ASP.Net Here's a couple of the lines of my dependency installer: container.Register(Component.For<IApiHra>() .ImplementedBy(typeof(ApiHra)) .LifeStyle

Resolving Interface with generic type constraint with Castle Windsor

梦想与她 提交于 2019-12-10 18:07:04
问题 Given the interface where FooRequest and FooResponse are abstract: public interface IFooHandler<TRequest, TResponse> where TRequest : FooRequest where TResponse : FooResponse { TResponse CheckFoo(TRequest request); } An implementation of: public class MyFooHandler : IFooHandler<MyFooRequest, MyFooResponse> { public MyFooResponse CheckFoo(MyFooRequest request) { /* check for foos */ } } How would I register this in Castle Windsor so I can resolve it using (where IoCContainer is a

Migrate from .NET MVC 1 to MVC 2 RC

ⅰ亾dé卋堺 提交于 2019-12-10 17:34:35
问题 I've migrated a MVC1 project to MVC2 RC, and now the site doesn't work at all. I get the error "Entry point was not found." I migrated the project following this link I'm using Castle Windsor as DI. Here is a part of global.asax.cs public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Main", action = "Index", id = "" }); } protected void Application_Start() {

Issues setting up FluentValidation with Castle.Windsor

谁都会走 提交于 2019-12-10 17:17:50
问题 I have an asp.net MVC 4.5 application with Castle.Windsor 3.2.2 as DI and I'm trying to add FluentValidation version 5.0.0.1 for the first time. I created the factory inheriting from ValidatorFactoryBase public class WindsorFluentValidatorFactory : ValidatorFactoryBase { private readonly IKernel _kernel; public WindsorFluentValidatorFactory(IKernel kernel) { _kernel = kernel; } public override IValidator CreateInstance(Type validatorType) { return _kernel.HasComponent(validatorType) ? _kernel

Remove components in Castle Windsor 3

倖福魔咒の 提交于 2019-12-10 16:58:12
问题 I am using the TypedFactoryFacility in Castle Windsor to allow me to use the interface-factory dependency injection. I am having issues with the automatic delegate-factory injecting Func into automatically resolved components when these are not required (should be Null). I would like to keep the TypedFactoryFacility, but remove the DelegateFactory, as per this question: Can Windsor's TypedFactoryFacility's implicit delegate factory registration be disabled? Unfortunately there is now no way

How to revert to old CollectionResolver behavior in Castle 3?

隐身守侯 提交于 2019-12-10 15:55:42
问题 I'm using the CollectionResolver (more specifically the ListResolver) to support scenarios where we want to inject multiple implementations of an interface. The CollectionResolver's behavior has been impacted by the changes to ResolveAll() in Castle 3. Previously, ResolveAll() would only return those implementations that could be resolved, and silently ignore any registered implementations that could not be resolved. Now, ResolveAll() fails if ANY one of the registered implementations cannot