castle-windsor

Automapper Custom Resolver - Inject Repository into constructor

淺唱寂寞╮ 提交于 2019-12-01 18:24:12
I am trying to create a custom resolver for automapper which needs to access one of my data repositories to retreive the logged in users account. Here is my code so far... public class FollowingResolver : ValueResolver<Audio, bool> { readonly IIdentityTasks identityTasks; public FollowingResolver(IIdentityTasks identitTasks) { this.identityTasks = identitTasks; } protected override bool ResolveCore(Audio source) { var user = identityTasks.GetCurrentIdentity(); if (user != null) return user.IsFollowingUser(source.DJAccount); return false; } } However I am getting this error: FollowingResolver'

What is best practise when instantiating a Castle Windsor container in a class library? [duplicate]

邮差的信 提交于 2019-12-01 18:00:17
This question already has an answer here: Dependency Inject (DI) “friendly” library 4 answers I am wondering where the best place to instantiate the castle Windsor container is in a class library. Should I simply do it in the constructor of the class I am using or is there a single entry point for assemblies that I am unaware of? Thanks. The configuration of an injected object graph is entirely dependent on the needs of the application that actually uses it. The point of using the container is to be able to configure dependencies at runtime - a library doesn't know anything about how it's

Where can I download the Castle Windsor WcfIntegration Facilities dll?

核能气质少年 提交于 2019-12-01 17:40:26
I would like to integrate Castle Windsor into a WCF project and have read that you can hook it up using the WcfIntegration facility but I am unable to find where to download the dll. Can anyone help? It's in NuGet now with all of the other 3.0 beta stuff. Install-Package Castle.WcfIntegrationFacility http://nuget.org/List/Packages/Castle.WcfIntegrationFacility Update Just to follow up, The one in nuget is targeted for Windsor 3.0 beta 1. I found out the hard way that some of the other facilities do not yet support 3.0 beta 1. Specifically, if you're using the NHibernate or AutoTx facilities,

Castle Windsor: How to programatically pass a list parameter to the container?

爷,独闯天下 提交于 2019-12-01 17:22:47
Is it possible to pass a list constructor parameter when resolving a type? I want to use a programmatic configuration if possible. I've been playing around with the Parameters method as shown below, but I've not yet stumbled upon the answer. container.Register( Component .For<IDoSomething>() .ImplementedBy<DoSomething>() .Parameters(...) ); The DoSomething class would look something like this public class DoSomething : IDoSomething { public DoSomething(List<string> listOfStrings) { ... } } Aha! container.Register( Component .For<IDoSomething>() .ImplementedBy<DoSomething>() .Parameters(new {

Castle Windsor with Multiple Constructors

旧时模样 提交于 2019-12-01 17:04:19
I am currently undertaking a conversion, from to the use of Ninject, to the current release of Castle Windsor for a simple C# .NET application. For the most part, the conversion has gone well and the implementation of the containers has executed flawlessly. I am however having a small issue with my repository objects. I have a user repository object that is coded in the following fashion: public class UserRepository : IUserRepository { public UserRepository(IObjectContext objectContext) { // Check that the supplied arguments are valid. Validate.Arguments.IsNotNull(objectContext, "objectContext

Where can I download the Castle Windsor WcfIntegration Facilities dll?

无人久伴 提交于 2019-12-01 16:57:41
问题 I would like to integrate Castle Windsor into a WCF project and have read that you can hook it up using the WcfIntegration facility but I am unable to find where to download the dll. Can anyone help? 回答1: It's in NuGet now with all of the other 3.0 beta stuff. Install-Package Castle.WcfIntegrationFacility http://nuget.org/List/Packages/Castle.WcfIntegrationFacility Update Just to follow up, The one in nuget is targeted for Windsor 3.0 beta 1. I found out the hard way that some of the other

Castle Windsor: How to programatically pass a list parameter to the container?

送分小仙女□ 提交于 2019-12-01 16:52:08
问题 Is it possible to pass a list constructor parameter when resolving a type? I want to use a programmatic configuration if possible. I've been playing around with the Parameters method as shown below, but I've not yet stumbled upon the answer. container.Register( Component .For<IDoSomething>() .ImplementedBy<DoSomething>() .Parameters(...) ); The DoSomething class would look something like this public class DoSomething : IDoSomething { public DoSomething(List<string> listOfStrings) { ... } }

Castle Windsor with Multiple Constructors

筅森魡賤 提交于 2019-12-01 16:45:00
问题 I am currently undertaking a conversion, from to the use of Ninject, to the current release of Castle Windsor for a simple C# .NET application. For the most part, the conversion has gone well and the implementation of the containers has executed flawlessly. I am however having a small issue with my repository objects. I have a user repository object that is coded in the following fashion: public class UserRepository : IUserRepository { public UserRepository(IObjectContext objectContext) { //

Castle.Windsor and HttpContextWrapper

天大地大妈咪最大 提交于 2019-12-01 13:31:44
HttpContextWrapper and HttpContextBase, as explained here , were introduced to make HttpContext more mockable/testable. I'm trying to use it with S#arp Architecture , and hitting some problems. My MVC Controllers are set up to accept an HttpContextBase argument in the constructor, and during Application_Start, HttpContextBase is registered with Castle.Windor as follows: container.Register(Component.For<HttpContextBase>().UsingFactoryMethod( () => new HttpContextWrapper(HttpContext.Current))); This seemed to work OK for a bit, but then I realised Castle is only running that Factory method once,

Decorators with different constructor arguments

时光怂恿深爱的人放手 提交于 2019-12-01 13:16:10
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 = decoratedRecorder; } public void Add(int value) { decoratedRecorder.Add(value); System.Console.WriteLine(