public void Init() { var builder = new PersistentProxyBuilder(); generator = new MyProxyGenerator(builder); interceptor = new LogInvocationInterceptor(); }
public void ExplicitInterface_AsAdditionalInterfaceToProxy_OnClassProxy_WithoutBaseCalls5() { interceptor.Proceed = false; generator.CheckNotGenericType(typeof(SimpleInterfaceExplicit)); generator.CheckNotGenericTypes(new[] { typeof(ISimpleInterface) }); var proxyType = generator.ProxyBuilder.CreateClassProxyType(typeof(SimpleInterfaceExplicit), new[] { typeof(ISimpleInterface) }, ProxyGenerationOptions.Default); Assert.AreEqual(proxyType.Name, "SimpleInterfaceExplicitProxy"); Assert.AreEqual(proxyType.FullName, "Castle.Proxies.SimpleInterfaceExplicitProxy"); Assert.AreEqual(proxyType.Assembly.FullName, "DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=a621a9e7e5c32e69"); Assert.AreEqual(proxyType.AssemblyQualifiedName, "Castle.Proxies.SimpleInterfaceExplicitProxy, DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=a621a9e7e5c32e69"); Assert.AreEqual(proxyType.GetCustomAttributes().Count(), 2); Assert.AreEqual(proxyType.GetProperties().Count(), 0); var arguments = MyProxyGenerator.BuildArgumentList(ProxyGenerationOptions.Default, new IInterceptor[] { interceptor }); Assert.AreEqual(arguments.Count, 1); var mixins = ProxyGenerationOptions.Default.MixinData.Mixins; Assert.AreEqual(mixins.Count(), 0); Assert.IsNull(ProxyGenerationOptions.Default.Selector); Assert.IsNotNull(arguments[0]); Assert.AreEqual(arguments[0], new IInterceptor[] { interceptor }); }
static void Main(string[] args) { IList <string> listProxy = MyProxyGenerator.Create <IList <string> >(new ListProxy <string>(new List <string>() { "aa", "bb" })); bool b1 = listProxy.Contains("aa"); bool b2 = listProxy.Contains("cc"); int count = listProxy.Count; string s = listProxy[1]; }