// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using Castle.Core; using Castle.DynamicProxy; namespace E { public interface IX { } public class CX : IX { } public class Program { public static void Main(string[] args) { IX o = new CX(); Console.WriteLine(o == o); ProxyGenerator gen = new ProxyGenerator(); IX o1 = (IX)gen.CreateInterfaceProxyWithTarget(typeof(IX), o, new IInterceptor[0]); IX o2 = (IX)gen.CreateInterfaceProxyWithTarget(typeof(IX), o, new IInterceptor[0]); Console.WriteLine(o1 == o2); IX o3 = (IX)ProxyUtil.GetUnproxiedInstance(o2); Console.WriteLine(o == o3); } } }