castle-windsor

Integrating Castle Windsor with SignalR - how should I approach this?

我是研究僧i 提交于 2019-11-30 09:18:10
I am getting started with SignalR, and it works great once everything is configured. However, almost all the applications that I work on use Castle Windsor, so it would be great to be able to use them together. The reason that I want to do this is so that I can use Castle dependencies/services inside of a persistent connection. I dug around in the source code, and it looks like I could either replace DependencyResolver with a Castle based one (i.e., Castle implementing IDependencyResolver), or I could change the usage of DependencyResolver to Castle. Which one of these is a better idea? Is

Inject App Settings using Windsor

此生再无相见时 提交于 2019-11-30 08:38:32
How can I inject the value of an appSettings entry (from app.config or web.config) into a service using the Windsor container? If I wanted to inject the value of a Windsor property into a service, I would do something like this: <properties> <importantIntegerProperty>666</importantIntegerProperty> </properties> <component id="myComponent" service="MyApp.IService, MyApp" type="MyApp.Service, MyApp" > <parameters> <importantInteger>#{importantIntegerProperty}</importantInteger> </parameters> </component> However, what I'd really like to do is take the value represented by #

Does Castle-Windsor support ForwardedTypes via XML configuration

妖精的绣舞 提交于 2019-11-30 08:32:30
问题 I have a class that implements multiple interfaces. I would like to register these interfaces via XML. All I've found is documentation for the new Fluent Interface. Is this option supported via XML? What would be involved in adding this feature? 回答1: [ Update ] This is now possible in Windsor 2.1 or newer. See the documentation for syntax here. This feature has not been implemented in the XML interpreter as of yet.. however it is not difficult to add support for it via a facility (obviously

Castle Windsor register class with constructor parameters

送分小仙女□ 提交于 2019-11-30 08:01:31
I have the following class: public class DatabaseFactory<C> : Disposable, IDatabaseFactory<C> where C : DbContext, BaseContext, new() { private C dataContext; private string connectionString; public DatabaseFactory(string connectionString) { this.connectionString = connectionString; } public C Get() { return dataContext ?? (dataContext = Activator.CreateInstance(typeof(C), new object[] {connectionString}) as C); } protected override void DisposeCore() { if (dataContext != null) dataContext.Dispose(); } } When I try to start the web api, I get the following error: Can't create component 'MyApp

Register types based on base class

烈酒焚心 提交于 2019-11-30 07:42:13
问题 I'm trying to figure out Windsor as an IOC container. The problem I'm facing right now is to register all of my viewmodels at once. I've taken a look at the docs and thought that the following code should work. However, when I check the container afterwards, nothing is registered. container.Register(Classes.FromThisAssembly() .BasedOn<ViewModelBase>() .LifestyleTransient()); where ViewModelBase is my baseclass. Also tried the following: container.Register(Classes.FromThisAssembly()

Castle Windsor ApiController Factory implementation for ASP.NET Web API

谁说胖子不能爱 提交于 2019-11-30 07:11:01
问题 I know it's possible to use DependencyResolver and register Castle Windsor with MVC but due to the issues described in https://stackoverflow.com/a/4889222/139392 we have stuck to the WindsorControllerFactory method of implementation on our MVC projects. However it looks like the ApiControllers are using some other kind of factory as Castle Windsor is unable to inject the dependencies. Has anyone figured out how to use Castle Windsor with ASP.NET Web API and MVC without using the

IoC - Multiple implementations support for a single interface

左心房为你撑大大i 提交于 2019-11-30 06:37:46
I am wondering why .Net IoC containers do not easily support multiple implementations for a single interface! May be I am wrong, but as far I have seen, frameworks like Ninject partially supports this feature using annotations ( how? ). I do not think other frameworks like Windsor or simple injector have an easy mechanism to support this scenario. Is there any reason why this is not supported by many frameworks? AFAIK, one of the most important reasons to use interfaces is to achieve loose coupling. If the frameworks designed to improve loose coupling, do not fluently support multiple

Why does Castle Windsor hold onto transient objects?

≯℡__Kan透↙ 提交于 2019-11-30 06:33:37
问题 Recently I noticed my application appears to be eating memory that never gets released. After profiling with CLRProfiler I've found that the Castle Windsor container I'm using is holding onto objects. These objects are declared with the lifestyle="transient" attribute in the config xml. I've found if I put an explicit call to IWindsorContainer.Release(hangingObject) , that it will drop its references. This is causing a problem though, I wasn't expecting that with a transient lifestyle object

What is the best practice to implement multi tenancy in ASP.NET MVC using Castle Windsor?

好久不见. 提交于 2019-11-30 05:32:51
I have a service with two different implementations and I would like to inject into the controllers constructor, depends on a criteria (at the moment the criteria is a simple value stored in session). Here is what I got now... Service interface: public interface IService { string GetSampleText(); } Implementation #1: public class FirstService : IService { string GetSampleText() { return "First Service"; } } Implementation #2: public class SecondService : IService { string GetSampleText() { return "Second Service"; } } Registration in a Windsor installer class: container.Register(AllTypes

Castle.Windsor lifestyle depending on context?

匆匆过客 提交于 2019-11-30 04:35:39
I have a web application where many components are registered using .LifestylePerWebRequest() , now I've decided to implement Quartz.NET , a .NET job scheduling library, which executes in separate threads, and not the Request thread. As such, HttpContext.Current yields null . My services, repositories, and IDbConnection were instanced so far using .LifestylePerWebRequest() because it made it easier to dispose of them when the requests ended. Now I want to use these components in both scenarios, during web requests I want them to remain unaffected, and in non-request contexts I want them to use