castle-dynamicproxy

Why does Autofixture w/ AutoMoqCustomization stop complaining about lack of parameterless constructor when class is sealed?

£可爱£侵袭症+ 提交于 2019-11-30 19:19:24
When I use Moq directly to mock IBuilderFactory and instantiate BuilderService myself in a unit test, I can get a passing test which verifies that the Create() method of IBuilderFactory is called exactly once. However, when I use Autofixture with AutoMoqCustomization , freezing a mock of IBuilderFactory and instantiating BuilderService with fixture.Create<BuilderService> , I get the following exception: System.ArgumentException: Can not instantiate proxy of class: OddBehaviorTests.CubeBuilder. Could not find a parameterless constructor. Parameter name: constructorArguments If I make

Castle DynamicProxy : How to Proxy Equals when proxying an interface?

末鹿安然 提交于 2019-11-30 09:03:40
I need to use Castle DynamicProxy to proxy an interface by providing an instance of it to ProxyGenerator.CreateInterfaceProxyWithTarget. I also need to make sure that calls to Equals, GetHashCode and ToString hits the methods on the concrete instance, that I am passing, and I can't get that to work. In other words, I'd like this small sample to print True twice, while in fact it prints True,False : using System; using Castle.Core.Interceptor; using Castle.DynamicProxy; public interface IDummy { string Name { get; set; } } class Dummy : IDummy { public string Name { get; set; } public bool

Why does Autofixture w/ AutoMoqCustomization stop complaining about lack of parameterless constructor when class is sealed?

六月ゝ 毕业季﹏ 提交于 2019-11-30 04:20:51
问题 When I use Moq directly to mock IBuilderFactory and instantiate BuilderService myself in a unit test, I can get a passing test which verifies that the Create() method of IBuilderFactory is called exactly once. However, when I use Autofixture with AutoMoqCustomization , freezing a mock of IBuilderFactory and instantiating BuilderService with fixture.Create<BuilderService> , I get the following exception: System.ArgumentException: Can not instantiate proxy of class: OddBehaviorTests.CubeBuilder

What are the differences between LinFu.DynamicProxy and Castle.DynamicProxy?

北城以北 提交于 2019-11-29 23:54:25
I am looking at adding logic to a library I am working on that would require the need for a Dynamic Proxy. I would like to get some advice from user's who have used these two library's in a production environment. Does one out perform the other, were there any shortcoming's which made you have to switch to the other, etc. Basically tell me your experiences with the library's. The answers will help me decide which one to use. -- Edit -- I forgot to mention that the library I am developing will support Mono, therefore any knowledge you can share about the two libraries and their support for Mono

Castle DynamicProxy : How to Proxy Equals when proxying an interface?

若如初见. 提交于 2019-11-29 13:19:37
问题 I need to use Castle DynamicProxy to proxy an interface by providing an instance of it to ProxyGenerator.CreateInterfaceProxyWithTarget. I also need to make sure that calls to Equals, GetHashCode and ToString hits the methods on the concrete instance, that I am passing, and I can't get that to work. In other words, I'd like this small sample to print True twice, while in fact it prints True,False : using System; using Castle.Core.Interceptor; using Castle.DynamicProxy; public interface IDummy

Applying AOP

我是研究僧i 提交于 2019-11-29 06:01:04
I've been using some basic AOP style solutions for cross-cutting concerns like security, logging, validation, etc. My solution has envolved around Castle Windsor and DynamicProxy. I've gone down this route because I can apply everything using a Boo based DSL and keep my code clean of Attributes. I was told at the weekend to have a look at PostSharp as it's supposed to be a "better" solution. I've had a quick look at PostSharp, but I've been put off by the Attribute usage. Has anyone tried both solutions and would care to share their experiences? I only looked at castle-windsor for a short time

Castle Windsor intercept method call from within the class

家住魔仙堡 提交于 2019-11-29 05:14:54
We have components registrations in Castle Windsor container like so void RegisterComponent<TInterface, TImplementation>() { var component = Component.For<TInterface>().ImplementedBy<TImplementation>(); component.Interceptors<SomeInterceptor>(); container.Register(component); } However we got to the problem that when we do a method call from within the class it does not get intercepted. For example we have component like ServiceA : IService { public void MethodA1() { // do some stuff } public void MethodA2() { MethodA1(); } } And if we call MethodA2 or MethodA1 methods from some other class it

Castle Dynamic Proxy not intercepting method calls when invoked from within the class

笑着哭i 提交于 2019-11-28 21:29:54
I have run into a bit of (what I think is) strange behaviour when using Castle's Dynamic Proxy. With the following code: class Program { static void Main(string[] args) { var c = new InterceptedClass(); var i = new Interceptor(); var cp = new ProxyGenerator().CreateClassProxyWithTarget(c, i); cp.Method1(); cp.Method2(); Console.ReadLine(); } } public class Interceptor : IInterceptor { public void Intercept(IInvocation invocation) { Console.WriteLine(string.Format("Intercepted call to: " + invocation.Method.Name)); invocation.Proceed(); } } public class InterceptedClass { public virtual void

What are the differences between LinFu.DynamicProxy and Castle.DynamicProxy?

十年热恋 提交于 2019-11-28 21:01:04
问题 I am looking at adding logic to a library I am working on that would require the need for a Dynamic Proxy. I would like to get some advice from user's who have used these two library's in a production environment. Does one out perform the other, were there any shortcoming's which made you have to switch to the other, etc. Basically tell me your experiences with the library's. The answers will help me decide which one to use. -- Edit -- I forgot to mention that the library I am developing will

NuGet: NHibernate, Castle.Core 3.0 and where is ProxyFactoryFactory?

浪子不回头ぞ 提交于 2019-11-28 09:29:13
I installed with NuGet the packages NHibernate and Castle.Core 3.0 for a new project. Usually we copied around the dlls manually; it is the first time I do that with NuGet. Now I can't find out how to configure the ProxyFactoryFactory, or let's say, I can't find it. I referenced NHibernate and Castle.Core (the only dll I could find in the Castle.Core - package) within the project, and configured the following: <property name="proxyfactory.factory_class"> NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle </property> This leads to: Class Initialization method Tests