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
3
votes
1 answer

How can multiple interfaces with multiple classes be merged using DynamicProxy?

Suppose we have an interface ICat that is derived from ICatBase and ICatExtension as shown below. For both distinct interfaces, an implementation is available, CatBase and CatExtension. How can Castle's DynamicProxy be used to merge these into an…
Ringo
  • 83
  • 6
3
votes
1 answer

Can a Castle DynamicProxy interceptor change argument values?

We're using DynamicProxy in a project. I've created an interceptor for a few methods. I know that it's possible to get the method arguments inside of a Castle.DynamicProxy.IInterceptor object. Can an interceptor change the value of the arguments…
user677526
3
votes
3 answers

Castle dynamic proxy and INotifyPropertyChanged on WPF

I'm wrapping my entities with a proxy using Castle DP, my entities implement by themselves INotifyPropertyChanged. and raise the event when set is called. i wrote some unit test on the wrapping to see that the propertychanged event is fired when i…
Chen Kinnrot
  • 20,609
  • 17
  • 79
  • 141
3
votes
5 answers

Castle Windsor intercept method call from within the class

We have components registrations in Castle Windsor container like so void RegisterComponent() { var component = Component.For().ImplementedBy(); …
Nikolay K
  • 3,770
  • 3
  • 25
  • 37
3
votes
1 answer

Is it possible to add a property to a type, via a DynamicProxy?

I'm using Castle DynamicProxy to create a proxy of a given type at runtime - including a couple mixins. I'm trying to figure out if it's possible to also add arbitrary properties to the proxy, e.g.: class BaseType { string Foo { get; set; } } and…
Bobby
  • 1,666
  • 3
  • 16
  • 27
3
votes
1 answer

How can I create a DynamicProxy for a WCF proxy that is generated by ChannelFactory?

I am using ChannelFactory to create a proxy at run-time for a WCF service. I would like to use the DynamicProxy Castle project to create a dynamic proxy on top of the WCF proxy so that I can intercept calls and do impersonation. I'm getting an error…
Max Schmeling
  • 12,363
  • 14
  • 66
  • 109
3
votes
2 answers

Changing method access modifier with reflection

I have a scenario where I use castle dynamic proxy to be able to intercept and log message calls to any given class(let's call it the target class). I do this by wrapping the target-class in a class that creates a proxy of the class with a…
iCediCe
  • 1,672
  • 1
  • 15
  • 32
3
votes
1 answer

Create dynamic proxy that implements multiple interfaces simultaneously

I can't quite figure out how to use dynamic proxy how to implement multiple interfaces at the same time. Using a third party library I have something like interface ISubscribe { Consume(T msg); } I would like to dynamically create a class that…
George Mauer
  • 117,483
  • 131
  • 382
  • 612
3
votes
2 answers

Caslte Windsor Proxy Generation Options

I've been struggling to find anything online, so I thought I'd see if anyone else knows how to sort this little issue I'm having. I've got a scenario where I want to create a proxy object so that various other interfaces can be added to the same…
Adam Goss
  • 1,017
  • 3
  • 14
  • 22
3
votes
1 answer

Autofac Intercept Target Method

I'm using Autofac.Extras.DynamicProxy2 to perform some method interception on a service implementation. The service has quite a few methods and I only want to target a few. Is there a better practice besides than checking for invocation target…
twifosp
  • 277
  • 2
  • 7
  • 16
3
votes
1 answer

Castle DynamicProxy breaks EventWiring Listeners

Story started this way, I used Castle EventWiring facility to define listeners to events in my classes, and it worked fine, I used to raise events like this: if (null != BlaBlaEvent) { BlaBlaEvent(someData); } Recently I faced a business…
Tamim Al Manaseer
  • 3,554
  • 3
  • 24
  • 33
3
votes
1 answer

Castle interface proxy with a dynamic target

I am trying to use Castle DynamicProxy to implement a typesafe version of a SignalR Hub. The goal being when I use Clients.All rather than getting a dynamic object back I have an interface to use. The code is rather hacky at the moment but I wanted…
user1618236
3
votes
2 answers

How do you give a C# Auto-Property a default value in DynamicProxy?

namespace ConsoleApplication15 { using System; using Castle.DynamicProxy; public class Test { private SubTestClass subTestClass; public string Status { get { return this.subTestClass.SubStatus; } …
Bassam Alugili
  • 16,345
  • 7
  • 52
  • 70
3
votes
2 answers

Ninject interception proxying class with non empty constructor via castle dynamic proxy

I am basing most of my current implementation off the information provided here: Ninject Intercept any method with certain attribute? I use a custom planning strategy class which looks for all methods with given attributes (not ninject interceptor…
Grofit
  • 17,693
  • 24
  • 96
  • 176
3
votes
1 answer

Should Castle DynamicProxy IInterceptor or ProxyGenerator be cached?

I'm using StructureMap to Enrich some of my objects with an instance call to ProxyGenerator.CreateInterfaceProxyWithTarget(myObject, MYInterceptor) Currently I have the MYInterceptor inside my container, should I implement any type of caching for…
Chris Marisic
  • 32,487
  • 24
  • 164
  • 258