Questions tagged [castle-dynamicproxy]

Castle DynamicProxy is a library for generating lightweight .NET proxies on the fly at runtime. Proxy objects allow calls to members of an object to be intercepted without modifying the code of the class.

Castle DynamicProxy is a library for generating lightweight .NET proxies on the fly at runtime. Proxy objects allow calls to members of an object to be intercepted without modifying the code of the class.

Resources

335 questions
8
votes
2 answers

Can I define custom attributes for proxy type in Castle Windsor

I have a class that I proxy it with Castle Dynamic Proxy. I want to add some custom Attributes to proxy methods (which is not defined in proxied class). Is this possible. I want this because I want to generate ASP.NET Web API layer for my…
8
votes
1 answer

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

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…
Jeff
  • 2,191
  • 4
  • 30
  • 49
7
votes
3 answers

Castle Windsor InternalsVisibleTo Silverlight

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…
Jeff
  • 35,755
  • 15
  • 108
  • 220
7
votes
5 answers

Make object dynamically implement an interface in code

I want to make this test pass - anyone got an idea how to do that? public class Something { public string Name {get; set} } public interface IWithId { public Guid Id {get; set} } public class IdExtender { public static Object…
Jan
  • 6,532
  • 9
  • 37
  • 48
7
votes
2 answers

Autofac class interception doesn't work in a certain setup

I have an IoC setup with Autofac and use AoP interceptors. Normally, I use interface interceptors registered like this: var builder = new ContainerBuilder(); builder.RegisterType() .As() .UsingConstructor(new Type[0]) …
Jacek Gorgoń
  • 3,206
  • 1
  • 26
  • 43
7
votes
4 answers

How to detect if a Type is a generated DynamicProxy without referencing Castle DynamicProxy?

I am using castle DynamicProxy and was wondering if there is a way of detecting if a Type is a proxy without referencing Castle DynamicProxy? So while I am using Castle DynamicProxy as an example I would like code that would work for any in memory…
Simon
  • 33,714
  • 21
  • 133
  • 202
6
votes
3 answers

Dynamic cast to generic type

Just a quickie before the weekend rolls in... I have a Method with the following signature, that I need to invoke: public interface IObjectProvider { T Get(Predicate condition); } This will provide me with a T from whatever kind of…
6
votes
1 answer

Which `[InternalsVisibleTo]` for .NET Framework and .NET Standard / Core framework assemblies?

I'm having an issue with cross-assembly / friend assembly type visibility. I have the following program (which I sign / strong-name). It tells Castle DynamicProxy (I'm using version 4.2.1 of the Castle.Core NuGet package) to create a proxy for my…
6
votes
4 answers

What's the simplest way to intercept a method call for added functionality?

Suppose i have a repository that returns a list of Posts. The repository interface has a GetAll() method which does what it suggests. Now in keeping with the theory that i shouldn't be putting domain logic in the repository, i want to intercept…
Matt Kocaj
  • 11,278
  • 6
  • 51
  • 79
6
votes
2 answers

How DispatchProxy compare to Castle DynamicProxy?

Some time ago I published an open source library which heavily relies on Castle DynamicProxy. Now that .NET Core 1.x RTM is out, I don't find how I could support .NET Core (Castle DynamicProxy still doesn't work on .NET Core...), until I met…
Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
6
votes
1 answer

Castle Dynamic Proxy of Interface and not Derived Class

namespace DynamicInterception { public class Calculator { public virtual int Div(int a, int b) { try { return a / b; } catch (Exception ex) { …
A191919
  • 3,422
  • 7
  • 49
  • 93
6
votes
1 answer

Using Castle.Windsor to register an interceptor for only the derived class, not the base class

I am working on upgrading our project from .Net 2 to .Net4.5, at the same time I'm pushing as many references as I can to NuGet and making sure the versions are current. I am having a problem getting one of the tests to run The Test Classes: …
user1618236
6
votes
1 answer

Using Castle DynamicProxy to initialize a constructor with parameters

How to use Castle DynamicProxy to initialize a constructor with parameters? In this case MyClass(int). public class MyClass { public MyClass(){} public MyClass(int p1){} } Currently, CreateClassProxy() initializes MyClass().
Babak
  • 3,716
  • 6
  • 39
  • 56
6
votes
2 answers

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

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…
6
votes
0 answers

AOP with Castle Windsor

What I'm trying to achieve is AOP via attributes using Castle Windsor interceptors. I've had some success but having trouble with the aspects at the class level vs. the method level. If I use class level attributes only, all methods will be…
Juan Ayala
  • 3,388
  • 2
  • 19
  • 24
1
2
3
22 23