castle-windsor

Decorators with different constructor arguments

流过昼夜 提交于 2019-12-01 11:41:38
问题 Using Castle Windsor, I'd like to create a class that records an integer. But I'd like to decorate it several times with other classes. I can see how this works if all concretes involved have dependencies that can be resolved, but that's not the case here. Consider this code: public interface IRecorder { void Add(int value); } public class NotifyingRecorder : IRecorder { readonly IRecorder decoratedRecorder; public NotifyingRecorder(IRecorder decoratedRecorder) { this.decoratedRecorder =

Castle Windsor: Register components across multiple projects in solution

此生再无相见时 提交于 2019-12-01 09:42:17
I would like to use Castle Windsor for dependency injection for my solution consisting of the following projects: Mvc [ASP.NET MVC 3 Web Application]: presentation layer (depends on Business and Models ) Business [Class Library]: business layer (depends on DataAccess and Models ) DataAccess [Class Library]: data access layer (depends on Models ) Models [Class Library]: model layer In the business layer there is a class called PostService implementing IPostService that manages blog posts. The PostsController of the Mvc project depends on IPostService . However, PostService (the corresponding

Castle Windsor does not work under Medium Trust

给你一囗甜甜゛ 提交于 2019-12-01 09:01:44
问题 When attempting to run an ASP.NET MVC application which uses Castle Windsor, the following error occurs. Server Error in '/' Application. Inheritance security rules violated while overriding member: 'Castle.MicroKernel.DefaultKernel.InitializeLifetimeService()'. Security accessibility of the overriding method must match the security accessibility of the method being overriden. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack

Why is Castle Windsor trying to resolve my 'Content' and 'Scripts' folder as a controller?

只愿长相守 提交于 2019-12-01 08:08:08
问题 I have created an ASP.NET MVC application and am trying to use Castle Windsor as my IOC However, when the controllers are trying to resolve I am getting 'Content' and 'Scripts' into the 'controllerName' parameter in the CreateController(RequestContext requestContext, string controllerName) method. Needless to say these are not controllers. They appears to be the folders of the web site Why is it trying to register these as controllers? How do I ignore these folders?? thanks exception from

How do I connect the various pieces of my Web API Castle Windsor DI code?

别等时光非礼了梦想. 提交于 2019-12-01 08:05:25
How do I connect the various pieces of my Web API Castle Windsor DI code so that the Controller's routing selects the correct interface implementation? Note : After several false starts/dead ends and partial victories ( here and here and here ), I am going to bountify this ASAP for the maximum 500 points. But I'm only going to award a really good answer - IOW, one that is clear enough that I can understand it and "plug it in" to my project so that I can hook a given concrete class to a particular Controller. Here goes nothing: I have a Web API ("MVC") project. Really, though, this server

SignalR with IoC (Castle Windsor) - which lifetime for hubs?

邮差的信 提交于 2019-12-01 06:36:17
I'm just starting out with SignalR, and have created a custom resolver for SignalR, so I can use Castle Windsor to inject dependencies via hub constructors. I kind of assumed that I would only need to register the dependencies, but I found that it was also necessary to register the hubs themselves before my app would work. Is this expected? If so, what lifetime should I use for hubs? By default SignalR does not register each hub with the dependency resolver. Instead it uses an IAssemblyLocator to find available assemblies that might contain SignalR Hubs. Then the IHubDescriptorProvider

Castle Windsor: Register components across multiple projects in solution

只谈情不闲聊 提交于 2019-12-01 06:20:30
问题 I would like to use Castle Windsor for dependency injection for my solution consisting of the following projects: Mvc [ASP.NET MVC 3 Web Application]: presentation layer (depends on Business and Models ) Business [Class Library]: business layer (depends on DataAccess and Models ) DataAccess [Class Library]: data access layer (depends on Models ) Models [Class Library]: model layer In the business layer there is a class called PostService implementing IPostService that manages blog posts. The

Disposing of ViewModels in Caliburn Micro and Castle Windsor

≯℡__Kan透↙ 提交于 2019-12-01 06:06:17
I'm using Castle-Windsor as my container in a Caliburn-Micro Silverlight app. My ViewModel objects are reasonably chunky as they call WCF services and a bunch of other stuff. Therefore, when a window is closed I want to call container.Release(viewModel) so Castle can manage the whole decommission/disposal process, respecting the various lifecycles configured (as outlined in this post ). In my AppBootstrapper I have overridden GetInstance as follows: protected override object GetInstance(Type serviceType, string key) { if (string.IsNullOrEmpty(key)) return container.Resolve(serviceType); return

How do I connect the various pieces of my Web API Castle Windsor DI code?

℡╲_俬逩灬. 提交于 2019-12-01 05:53:08
问题 How do I connect the various pieces of my Web API Castle Windsor DI code so that the Controller's routing selects the correct interface implementation? Note : After several false starts/dead ends and partial victories (here and here and here), I am going to bountify this ASAP for the maximum 500 points. But I'm only going to award a really good answer - IOW, one that is clear enough that I can understand it and "plug it in" to my project so that I can hook a given concrete class to a

Where is the “magic” happening when a Controller instantiates the correct implementation of the Interface in Web API DI?

喜你入骨 提交于 2019-12-01 05:51:58
问题 It seems to me that somewhere a rabbit is being pulled out of a hat when it comes to DI in Web API Controllers. I grok that: 0) The Controller in a Web API project can be called with various classes to be instantiated, all of which implement the interface on which the Controller depends. e.g., with this Controller code: private readonly IDepartmentRepository _deptsRepository; public DepartmentsController(IDepartmentRepository deptsRepository) { if (deptsRepository == null) { throw new