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
4
votes
0 answers

Dynamic Proxying IEnumerable

I'm trying to create a dynamic proxy to a list of objects of a specific class. For example: var proxy = generator.CreateInterfaceProxyWithoutTarget(typeof (IEnumerable), …
HellSpam
  • 81
  • 1
  • 4
4
votes
1 answer

Ninject Interception dynamic proxy problems

I'm trying to set up interception to work with Ninject which we have been using as our dependency injection framework for a while. I have downloaded the interception extension from NuGet and tried it with both the Castle Dynamicproxy implementation…
4
votes
3 answers

How to unit test an interceptor?

I want to write some unit tests for an interceptor that intercepts the Loggable base class (which implements ILoggable). The Loggable base class has no methods to call and it is used only to be initialized by the logging facility. To my…
the_drow
  • 18,571
  • 25
  • 126
  • 193
4
votes
1 answer

Why Castle Windsor interceptor breaks the runtime binding of a method on a C# dynamic object?

I apologize in advance for the terminology overload involved in this question: the word dynamic in what follows will be used for both the C# dynamic typing feature and the Castle Windsor dynamic proxy feature. We basically have a scenario where, at…
Enrico Massone
  • 6,464
  • 1
  • 28
  • 56
4
votes
3 answers

Using Autofac Interface Interception with IAsyncInterceptor

I did use this documentation: https://autofaccn.readthedocs.io/en/latest/advanced/interceptors.html to implement Interface Interceptors. To handle my async calls I used the IAsyncInterceptor interface described…
Manuel R. Wenk
  • 367
  • 1
  • 12
4
votes
1 answer

Trying to make a Logging Interceptor for StructureMap using DynamicProxy

I'm trying to log calls from the UI (DNN module) to some of various services it uses, in a effort to profile how people are interacting with the site. I'm using StructureMap 2.5.3.0 and Log4Net I got things working well on individual class/instance…
baralong
  • 1,644
  • 1
  • 16
  • 32
4
votes
1 answer

Doing interception with structuremap

I'm trying to do some attribute-based interception using structuremap but I'm struggling to tie up the last loose ends. I have a custom Registry that scans my assemblies and in this Registry I have defined the following ITypeInterceptor whose…
soren.enemaerke
  • 4,770
  • 5
  • 53
  • 80
4
votes
2 answers

Dynamically creating properties in C# for use with XmlSerializer

I have an API that accepts xml messages. Suppose I have obtained object Thing from this API which looks like this: and is mapped to: [XmlRoot("Thing")] public class Thing { [XmlAttribute("shape")] public…
k_wisniewski
  • 2,439
  • 3
  • 24
  • 31
4
votes
2 answers

Attribute based interception with Castle.DynamicProxy and Simple Injector

I'm using Simple Injector in my project. For integration Simple Injector with Castle.DynamicProxy I'm using this example. I have following attributes: public class MyLogAttribute : Attribute { // some code. } public class MyTimerAttribute :…
sp7
  • 246
  • 3
  • 12
4
votes
3 answers

Access custom attribute on method from Castle Windsor interceptor

I am trying to access a custom attribute applied to a method within a castle interceptor, e.g.: [MyCustomAttribute(SomeParam = "attributeValue")] public virtual MyEntity Entity { get; set; } using the following code: internal class MyInterceptor :…
Rob West
  • 5,189
  • 1
  • 27
  • 42
4
votes
1 answer

Create proxy from existing object

Using Castle.DynamicProxy, what is the best way to create a proxy from an existing class instance? // The actual object Person steve = new Person() { Name = "Steve" }; // Create a proxy of the object Person fakeSteve =…
Aetherix
  • 2,150
  • 3
  • 24
  • 44
4
votes
1 answer

Castle Interface Proxy without target

I am trying to create a Proxy for an interface without a target and I always get a System.NullReferenceException when I invoke a method on the resulting proxy, although, the interceptor is always well invoked. Here it is the definition for the…
rollaeriu360
  • 305
  • 1
  • 11
4
votes
2 answers

Getting info about methods intercepted by Ninject

I am using Ninject interception to log errors on some of my methods. My interception class looks like this public class ErrorLoggingInterceptor : IInterceptor { private readonly ILogFactory _logFactory; public…
Igor Kulman
  • 16,211
  • 10
  • 57
  • 118
4
votes
1 answer

Castle dynamic proxy don't write custom attributes to proxy

I have simple unit test to reproduce situation: [Test] public void Castle_Writes_Attribute_To_Proxy() { var generator = new ProxyGenerator(); var proxy = generator.CreateClassProxy(); var type = proxy.GetType(); var prop =…
gdbdable
  • 4,445
  • 3
  • 30
  • 46
4
votes
2 answers

How to avoid double construction of proxy with DynamicProxy::CreateClassProxyWithTarget?

I am decorating an existing object using the CreateClassProxyWithTarget method. However, the constructor and therefore, initialization code, is being called twice. I already have a "constructed" instance (the target). I understand why this happens,…
Belvasis
  • 238
  • 1
  • 9