castle-dynamicproxy

Applying AOP

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 loo...

Using DynamicProxy as a decorator pattern in windsor container

I am looking for some info on using and configuring windsor to provide a dynamic proxy to intercept calls to an instance of another class. My class represents a resource that should be retained as a long lived instance by the container for performance reasons. However, sometimes this resource can transition into ununusable state, and...

Windsor MixIn is a Singleton?

I have a MixIn that requires some state to operate. I am registering it as so.. container.Register(Component.For(Of ICat) _ .ImplementedBy(Of Cat) _ .LifeStyle.Transient _ .Proxy.MixIns(New MyMixin())) When I call container.Resolve(of ICat), I get back a prox...

Castle DynamicProxy2: Get the Target inside an Interceptor?

I'm using Castle DynamicProxy2 to "tack on" interfaces to retrieve fields from a dictionary. For example, given the following class: public class DataContainer : IDataContainer { private Dictionary<string, object> _Fields = null; public Dictionary<string, object> Data { get { return _Fields ?? (_Fields = new Dictio...

Why does getting the mocked instance created with Moq throw a System.BadImageFormatException?

This question may be related to another question and it certainly results with a System.BadImageFormatException. Maybe it's the same thing but exposed differently? I have the following the code: public interface IFoo<T> where T : class, new() { T FooMethod(object o); } public interface IFooRepo { F GetFoo<T, F>() where T : class, ...

Generic IPropertyChangedNotifier using Dynamic Proxy and wcf serialization problem

I have implemented a generic IPropertyChangedNotifier using castle dynamic proxy. Here I intercept setter call in Proxy objects so that i don't have to raise PropertyChanged event in setters of my domain objects. The purpose was to use these proxy objects to bind it UI in a silevrlight application. The Problem is serialization of prox...

Retaining Base Class Attributes in Dynamic Proxies

I am using Castle DynamicProxy2. Is it possible to tell proxy object to inherit attributes on its Base Class(proxied class) and attributes on Properities of Base class. If not possible in Castle. Any other library for this purpose?? I have posted source of problem here http://stackoverflow.com/questions/1053328/generic-ipropertychanged...

Using generics when type is not known at compile time

Platform: C# 2.0 WinForms I have a factory class that provides an instantiation of a particular data mapper depending on the type that I send it, the code is as such: public static IDataMapper<T> GetMapper<T>() where T: IDto { Type mapperType = MapperLocator.GetMapper(typeof(T)); return (IDataMapper<T>)mapperType.Assembly.Crea...

Castle.DynamicProxy2 and Adding a Property at Run Time

I am using Castle.DynamicProxy2 and I am instantiating my proxy as such: private static T GenerateProxy() { ArrayList addtlInterfaces = new ArrayList(); addtlInterfaces.Add(typeof (INotifyPropertyChanged)); addtlInterfaces.Add(typeof (EntityStatus)); object entityProxy = ProxyGenerator.CreateClassProxy(typeof(T), ...

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 generated type. var generator = new ProxyGenerator(); var classProxy = generator.Create...

Castle.DynamicProxy2 generate proxy of delegate type

Is there a way to create a proxy of a delegate type and have it implement additional interfaces in DynamicProxy2 and also being able to intercept calls to the generated delegate? The way i normaly generate proxies throws an exception because delegate types are sealed. ...

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

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 te...

Castle Windsor: How to retrieve proxy for specific instance?

Hi! I'm using Castle Windsor in my project. Some registered components are intercepted. Because the components are registered through interfaces, Castle Windsor creates interface proxies (Castle Windsor creates a standalone type which implements the interface and delegates to the real implementation by using composition). Unfortunately ...

Getting underlying type of a proxy object

I'm using Castle DynamicProxy and my ViewModels are a proxy, something like this: namespace MyApplication.ViewModels { public class MyViewModel : BaseViewModel, IMyViewModel { } } a proxy of my viewmodel looks like this though: {Name = "IRootViewModelProxyffecb133f590422098ca7c0ac13b8f98" FullName = "IRootViewModelProxyffec...

castle dynamic proxy creation

I am implementing a design where my layer would sit between client and server, and whatever objects i get from server, i would wrap it in a transparent proxy and give to the client, that way i can keep a track of what changed in the object, so when saving it back, i would only send changed information. I looked at castle dynamic proxy, ...

NHibernate Proxy Validator changes in 2.1

Can someone please help me understand the following: In the previous version of NHibernate (2.0.1) the following property will validate and is compatible with the Castle Proxies: internal virtual BusinessObject Parent { get { /*code*/ } } However, in 2.1 it errors saying that the types should be 'public/protected virtual' or 'prote...

Whats the difference between PostSharp and Castle Dynamic Proxy?

Just wondering what the main differences are between these libraries, how they differ in features and functionality. Hoping for more information than I could find with a Google query... ...

Using dynamic proxy on NHibernate objects

Hi, I'm trying to use Castle.DynamicProxy2 to cleanup code within NHibernate persisted classes. Here is a simple version of it. The Pet class: public class Pet { public int Id { get; set; } public string Name { get; set; } public int Age { get; set; } } And its mapping file: <class name="Pet" table="Pet"> <id name="Id...

Castle Windsor Interceptor for private/protected method

Hi all, Is it true that in order for castle windsor's interceptor to intercept a method, that method needs to be declare public? ...

Problems with Castle DynamicProxy2 on .Net 3.5 SP1 on Win2003 Server

I've an mvc + nh asp.net application. On my dev machine (win 7 Ent) all works fine, if deployed on a Win 2k3 (tried 2 different vm and one phisical machine) I got the following error.. anyone can help? Cannot explain this issue (tried the same build, so i think it'a machine configuration issue).. Derived method 'set_ID' in type 'Custom...