castle-windsor

Using FluentValidation with Castle Windsor and Entity Framework 4.0 (POCO) in MVC2

喜夏-厌秋 提交于 2019-12-06 05:13:20
This isn't a very simple question, but hopefully someone has run across it. I am trying to get the following things working together: MVC2 FluentValidation Entity Framework 4.0 (POCO) Castle Windsor I've pretty much gotten everything working. I have Castle Windsor implemented and working with the Controllers being served up by the WindsorControllerFactory that is part of MVCContrib. I also have Castle serving up the FluentValidation validators as is described by this article: http://www.jeremyskinner.co.uk/2010/02/22/using-fluentvalidation-with-an-ioc-container/ My problem comes in when I try

Castle Windsor: How do I register a factory method, when the underlying type isn't accessible to my assembly?

♀尐吖头ヾ 提交于 2019-12-06 04:22:47
问题 I have a project where my business layer is constructed using DI, but I'm trying to go an additional step and use Windsor to manage object construction. Let's just say I have a pre-existing data layer (that I don't want to modify), that can be accessed via the following interface: interface IDataFactory { IDataService Service { get; } } A series of classes in my business layer depend on the services exposed through IDataFactory: IFactory factory = DataFactory.NewFactory(); IBusinessService

configure Castle Windosor and generic

不问归期 提交于 2019-12-06 03:32:16
this is my code in Global.asax WindsorContainer container = new WindsorContainer(); container.Register(Component.For(typeof(IRepository<>)) .ImplementedBy(typeof(NHRepository<>)) .LifeStyle.Transient) I've tried to translate it in a xml config file with this but didn't work <component id="NHRepository" service="NCommon.Data.IRepository'1, NCommon" type="NCommon.Data.NHibernate.NHRepository'1, NCommon.NHibernate" lifestyle="transient"> </component> How can I convert this code in a config file as Windsor.config ? Tanks Mirko You need to use backticks , not apostrophes <component id="NHRepository

Managing RavenDb session in Windsor under NServiceBus

佐手、 提交于 2019-12-06 03:19:32
问题 I'm using NServiceBus (3.2.2), RavenDB (1.2.2017-Unstable) and Windsor (3.0.0.4001) in an MVC 4 project. I have a IHandleMessages class that handles 3 different messages, and that needs an IDocumentSession, and therefore defines a property such as: public IDocumentSession DocumentSession { get; set; } I've copied the RavenDbUnitOfWork implementation from NServiceBus' website I've registered IDocumentStore, IDocumentSession and IManageUnitsOfWork in my Windsor container as follow: container

Passing parameters to UsingFactoryMethod in Castle Windsor

可紊 提交于 2019-12-06 03:14:31
How do I pass dynamic parameters to a UsingFactoryMethod registration? For example, I want to write something like: container.Register( Component.For<IFoo>() .UsingFactoryMethod(return DoSomethingAndReturnInstance(paremeter))); I need the parameters to be sent at runtime, like this: container.Resolve<IFoo>(new { parameter = value }); How can it be done? CreationContext.AdditionalParameters has the values you pass to Resolve You just have to use container.Register( Component.For<IFoo>() .UsingFactoryMethod((kernel, creationContext) => { var parameter = creationContext.AdditionalArguments[

Is it possible to have Castle Windsor resolve property dependancies when you dont have a reference to the container?

为君一笑 提交于 2019-12-06 02:42:22
问题 We have a solution whith multiple projects representing the layers of our application. e.g. Domain Data Logic WebUI Our Castle Windsor container is referenced from our web layer and we then cascade these dependancies up through our layers. For example... // In Domain public interface IFooRepository { void DoSomething(); } // In Data public class FooRepository : IFooRepository { public void DoSomething() { // Something is done } } // In Logic public class MyThingManager { private readonly

Internal logs for Castle Windsor

二次信任 提交于 2019-12-06 02:38:12
问题 How can I log Castle Windsor internal logs? For example if I had misconfigured Castle in a way that is failing to load the connection string, I want to know if I can log the errors from Castle when it tries to resolve the connection string. I'm using Log4Net Facility and I'm only able to see application logs, not Windsor logs. 回答1: Your call to WindsorContainer.Resolve<> will throw an exception if the resolution fails. You should log this exception in your "bootstrapping" code that is

Castle Windsor: PerThread vs PerWebRequest in ASP.NET

ぃ、小莉子 提交于 2019-12-06 02:34:57
问题 A lot of people seem to use the PerWebRequest lifestyle in web apps for managing certain contexts. I have two concerns: PerWebRequest has a dependency on an http module (right?). 2. PerWebRequest has a dependency on HttpContext. I have some ASP.NET code that fires off in a separate thread (and loses HttpContext). It seems that ASP.NET / IIS starts a new thread for each web request. Is there any reason not to just use the PerThread lifestyle and not have to worry about these dependencies? Or

Castle Windsor: Force resolver to use specified constructor

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 01:31:35
问题 Here is the example: interface IComponentA {}; class ComponentA : IComponentA { }; interface IComponentB { }; class ComponentB : IComponentB { }; interface IComponentC { }; class ComponentC : IComponentC { public ComponentC(IComponentA a) { Console.WriteLine("Constructor A"); } public ComponentC(IComponentB b) { Console.WriteLine("Constructor B"); } }; All these components are registered in Castle Windsor container. But class ComponentC has 2 overloaded constructors. Any of them can be used

Castle Windsor Typed Factory Facility equivalents

与世无争的帅哥 提交于 2019-12-05 22:59:45
问题 do any other .NET IoC containers provide equivalent functionality to the typed factory facility in Castle Windsor? e.g. if I am using an abstract factory pattern in a WPF application: public class MyViewModel { private IAnotherViewModelFactory factory; public void ShowAnotherViewModel() { viewController.ShowView(factory.GetAnotherViewModel()); } } I don't want to have to create a manual implementation of IAnotherViewModelFactory for every type of ViewModel I wish to show, I want the container