castle-windsor

Configuring Castle Windsor using xml/app.config

拈花ヽ惹草 提交于 2019-12-07 04:36:51
问题 I am currently building a sample application using Castle Windsor. The motto is to use xml/app.config to switch method interception on/off. I had used the Fluent API earlier and it worked as a charm. As the next step, I am trying to replace the fluent API with my xml. The gist of the code is as follows: A class called RandomOperations with two virtual methods. A LoggingAspect class which implements IInterceptor. A MyInterceptorsSelector class which implements IModelInterceptorsSelector A

Why does a Castle Windsor typed factory return the same instance when creating with different parameters

半世苍凉 提交于 2019-12-07 04:18:43
问题 I would expect the following to produce two separate instances when using the typed factory facility. using System; using Castle.Facilities.TypedFactory; using Castle.MicroKernel.Registration; using Castle.Windsor; namespace ConsoleApplication { class Program { static void Main(string[] args) { var container = new WindsorContainer(); container.AddFacility<TypedFactoryFacility>(); container.Register(Component .For<IFactory>() .AsFactory() .LifestyleSingleton()); container.Register(Component

System.InvalidProgramException when executing unit tests in MSTest after Microsoft Security update MS13-004

跟風遠走 提交于 2019-12-07 03:04:11
问题 After applying the Microsoft Security update on the 8th of January 2013 http://technet.microsoft.com/en-us/security/bulletin/ms13-004 we have started to experience failures in our CI builds on our build servers and locally when running tests on our development boxes. We get a System.InvalidProgramException: Common Language Runtime detected an invalid program . This only happens when running tests using MSTest that make use of Castle Windsor DynamicProxy although I am not convinced

IoC Castle Windsor - No parameterless constructor defined for this object

百般思念 提交于 2019-12-07 02:48:48
问题 I'm getting the 'No parameterless constructor defined for this object' on my controller when the controller and its dependencies are being registered accordingly via (DI/IoC) pattern using Castle Windsor. Can someone take a look at the following and see my error because i can't see it. Code for registration on global.asax public class MyApplication : System.Web.HttpApplication { public MvcApplication() { this.container = new WindsorContainer().Install(new DependencyInstaller()); } protected

How do I configure a single component instance providing multiple services in Castle.Windsor?

谁都会走 提交于 2019-12-07 02:32:24
问题 I'd like to configure the Windsor container so that a single, singleton-style instance can provide two or more services through the container. I've found that using the same type in multiple component declarations (XML-based config) will result in an instance of that type being created to provide each component's service interface, which is not the behaviour I desire. For example: interface IA { } interface IB { } class AB : IA, IB { ... } I want the one instance of AB to provide both the IA

Castle Windsor InternalsVisibleTo Silverlight

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 02:27:07
问题 I'm using Castle Windsor for SL v2.5.1.0. I have it proxy internal classes (the interfaces are public of course, but the implementation is internal, so that the consumer is only aware of the interface). I'm using the following attributes in my assembly with the internal classes [assembly: InternalsVisibleTo("Castle.Core, PublicKey

Multiple Decorator pattern in castle-windsor

爷,独闯天下 提交于 2019-12-06 18:27:49
问题 We are in the process of redesigning some legacy software to be more testable and have decided upon Dependency-Injection and Castle.Windsor to help us. First, our goal: * A number of decorators that all work on a data stream. * Multiple combinations of the decorators are possible and the root nodes in each case can be required to get data from different places. Technically, our design is as follows: interface IUpdateableValue<T> { T Get(); }; We have e.g. three sets of data to be retrieved

How can I decouple my application from my membership service?

最后都变了- 提交于 2019-12-06 15:43:34
I'm working on an ASP.NET MVC 4 project that uses Castle Windsor. One of the controllers has a dependency on MembershipService: public class FooController : Controller { private readonly MembershipService MembershipService; public FooController( MembershipService membershipService ) { MembershipService = membershipService; } [Authorize( Roles = "Administrator" )] public ActionResult DoSomething() { var user = MembershipService.GetUser( User.Identity.Name ); // etc... } } When I started writing unit tests for this controller (using Moq), I ran into a problem: private Mock<MembershipService>

IoC Castle Windsor in MVC routing problem

∥☆過路亽.° 提交于 2019-12-06 15:24:06
I've set up castle windsor in my mvc app. everything works great except it also catches routes that are of type link or image. The problem is that right before exiting from the controller and generating the view "GetControllerInstance" is executed with 'null' type. This happends anytime there a link on a page like: <link rel="stylesheet" type="text/css" href="non-existing.css"/> Or a link to an image that does not exist. Why is this happening? My windows class: public class WindsorControllerFactory : DefaultControllerFactory { #region Constants and Fields /// <summary> /// The container. /// <

Castle Windsor: How to prevent circular references in factory-created objects were the created objects refers back to the factory

狂风中的少年 提交于 2019-12-06 15:05:08
I am using windsor castle as my IoC container, and has run in to a bit of a problem. This is best explained in code, so I´ll give it a try. I have a factory class, that should provide me with implementations of a certain interface: public interface IObjectCreatorFactory { IObjectCreator GetObjectCreator(Type objectType); } public interface IObjectCreator { T CreateObject<T>(IDataRow data); bool SupportsType(Type type); } Implementation of the factory class could look like this, though I am not sure this is the way to go: public interface ObjectCreatorFactory:IObjectCreatorFactory { IEnumerable