/// <summary> /// Creates a proxy that inherits the proxied object's class. /// </summary> /// <remarks/> /// <returns>The generated proxy type.</returns> public override Type BuildProxyType() { BaseType = TargetType; if (BaseType.IsSealed || !ReflectionUtils.IsTypeVisible(BaseType, DynamicProxyManager.ASSEMBLY_NAME)) { throw new ArgumentException("Inheritance proxy cannot be created for a sealed or non-public class [" + BaseType.FullName + "]"); } TypeBuilder typeBuilder = CreateTypeBuilder(Name, BaseType); // declare field to hold reference to applicationContext FieldBuilder appContextField = DeclareApplicationContextInstanceField(typeBuilder); // create constructors ImplementConstructors(typeBuilder); // Implement IDependencyInjectionAware if necessary if (!typeof(ISupportsWebDependencyInjection).IsAssignableFrom(BaseType)) { ImplementIDependencyInjectionAware(typeBuilder, BaseType, appContextField); } // proxy base virtual methods BaseProxyMethodBuilder proxyMethodBuilder = new SupportsWebDependencyInjectionMethodBuilder(typeBuilder, this, appContextField, _staticCallbackMethod); foreach (MethodInfo methodToIntercept in _methodsToIntercept) { proxyMethodBuilder.BuildProxyMethod(methodToIntercept, null); } return(typeBuilder.CreateType()); }
/// <summary> /// Creates a proxy that inherits the proxied object's class. /// </summary> /// <remarks/> /// <returns>The generated proxy type.</returns> public override Type BuildProxyType() { BaseType = TargetType; if (BaseType.IsSealed || !ReflectionUtils.IsTypeVisible(BaseType, DynamicProxyManager.ASSEMBLY_NAME)) { throw new ArgumentException("Inheritance proxy cannot be created for a sealed or non-public class [" + BaseType.FullName + "]"); } TypeBuilder typeBuilder = CreateTypeBuilder(Name, BaseType); // declare field to hold reference to applicationContext FieldBuilder appContextField = DeclareApplicationContextInstanceField(typeBuilder); // create constructors ImplementConstructors(typeBuilder); // Implement IDependencyInjectionAware if necessary if (!typeof (ISupportsWebDependencyInjection).IsAssignableFrom(BaseType)) { ImplementIDependencyInjectionAware(typeBuilder, BaseType, appContextField); } // proxy base virtual methods BaseProxyMethodBuilder proxyMethodBuilder = new SupportsWebDependencyInjectionMethodBuilder(typeBuilder, this, appContextField, _staticCallbackMethod); foreach (MethodInfo methodToIntercept in _methodsToIntercept) { proxyMethodBuilder.BuildProxyMethod(methodToIntercept, null); } return typeBuilder.CreateType(); }