castle-windsor

List all types registered with a Castle Windsor container instance

怎甘沉沦 提交于 2019-11-27 05:49:49
问题 What's the easiest way of programatically listing registered types in Castle Windsor? Thanks 回答1: Use IKernel.GetAssignableHandlers(typeof(object)) : IWindsorContainer container = ... foreach (var handler in container.Kernel.GetAssignableHandlers(typeof(object))) { Console.WriteLine("{0} {1}", handler.ComponentModel.Service, handler.ComponentModel.Implementation); } 来源: https://stackoverflow.com/questions/1550190/list-all-types-registered-with-a-castle-windsor-container-instance

IoC, Where do you put the container?

自闭症网瘾萝莉.ら 提交于 2019-11-27 05:17:32
问题 I'm using castle windsor for a pet-project I'm working on. I'm starting to notice that I need to call the IoC container in different places in my code to create new objects. This dependency on the container makes my code harder to maintain. There are two solutions I've used to solve this problem I tried to create abstract factories as wrappers around the container that I could inject into parts of my application that need to create objects. This works but has some drawbacks because castle has

Castle Windsor IoC in an MVC application

余生颓废 提交于 2019-11-27 05:08:55
问题 Prepare for a wall of code... It's a long read, but it's as verbose as I can get. In response to Still lost on Repositories and Decoupling, ASP.NET MVC I think I am starting to get closer to understanding this all. I'm trying to get used to using this. Here is what I have so far. Project Project.Web (ASP.NET MVC 3.0 RC) Uses Project.Models Uses Project.Persistence Project Project.Models (Domain Objects) Membership.Member Membership.IMembershipProvider Project Project.Persistence (Fluent

Logging with Castle.Facilities.Logging and log4net

試著忘記壹切 提交于 2019-11-27 04:42:05
问题 I'm trying to get log4net integration for Castle Windsor working. I wrote my class with an public property of type ILogger and took the configuration in my app.config like following. <configuration> <configsections> <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" /> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> </configsections> <castle> <facilities> <facility id="logging" type="Castle

What is the difference between using the Service Locator anti-pattern and using the Castle Windsor container?" [closed]

▼魔方 西西 提交于 2019-11-27 02:58:18
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . Recently, I have been trying to understand what is the difference between using the Service Locator "anti-pattern" and using the Castle Windsor container. I have found some info here and there on the Internet and I have summarized what I have learned so far in an unfinished blog

Which Dependency Injection Tool Should I Use? [closed]

送分小仙女□ 提交于 2019-11-27 02:40:28
I am thinking about using Microsoft Unity for my Dependency Injection tool in our User Interface. Our Middle Tier already uses Castle Windsor, but I am thinking I should stick with Microsoft. Does anyone have any thoughts about what the best Dependency Injection tool is? Autofac Castle MicroKernel/Windsor PicoContainer.NET Puzzle.NFactory Spring.NET StructureMap Ninject Unity Simple Injector NauckIT.MicroKernel WINTER4NET ObjectBuilder Sticking to one container is not really important, if your system has been designed with the IoC/DI in mind. With the proper approach you can easily change the

Comparing Castle Windsor, Unity and StructureMap

二次信任 提交于 2019-11-27 02:38:15
In a follow up to Krzysztof’s statement that Windsor does a lot more than other IoC’s, I wanted to understand how these IoC’s stack up against each other and the benefits/additional facilities that castle Windsor provides. Are there any comparisons? Can someone help me understand the additional features that Castle Windsor provides over other IoC’s Mauricio Scheffer See here and here for a pretty thorough technical comparison of several IoC containers, although somewhat outdated by now (they're from before Windsor 2.0) However, I don't think there are really any vital features that Windsor

Castle Windsor - multiple implementation of an interface

此生再无相见时 提交于 2019-11-27 02:33:58
问题 While registering components in Castle Windsor, how do we bind specific implementation of an interface to a component that has a dependency on that interface. I know in advance which implementation needs to be used by the component. For example i created a sample console application based on code from several blogs and tutorials. Following is the code. public interface IReport { void LogReport(); } public interface ILogger { string Log(); } public class FileLogger : ILogger { public string

How to Inject Log4Net ILog implementations using Unity 2.0

依然范特西╮ 提交于 2019-11-27 02:09:41
问题 Ultimately this has to do with setting up log4Net but generically the problem is not logging specific. Generically what I am trying to figure out is how to do, in Microsoft Unity 2.0, something equivalent to what one gets with the Castle.Facilities.Logging.LoggingFacility. Namely the ability to declare a dependency on a logger and have the logger initialized with the Type of the object into which it is being injected. In the spirit of a test is worth a thousand words, here is what I need:

Injecting dependency into CustomAttribute using Castle Windsor

≯℡__Kan透↙ 提交于 2019-11-27 01:38:29
问题 In my ASP.Net MVC application I have implemented a Custom ActionFilter to Authorize users. I use CastleWindsor to provide dependency injection into all of the controllers as follows: protected virtual IWindsorContainer InitializeServiceLocator() { IWindsorContainer container = new WindsorContainer(); ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container)); container.RegisterControllers(typeof(HomeController).Assembly); ComponentRegistrar.AddComponentsTo