/// <summary> /// Create an AOP proxy for the given object. /// </summary> /// <param name="targetType">Type of the object.</param> /// <param name="targetName">The name of the object.</param> /// <param name="specificInterceptors">The set of interceptors that is specific to this /// object (may be empty but not null)</param> /// <param name="targetSource">The target source for the proxy, already pre-configured to access the object.</param> /// <returns>The AOP Proxy for the object.</returns> protected virtual object CreateProxy(Type targetType, string targetName, object[] specificInterceptors, ITargetSource targetSource) { ProxyFactory proxyFactory = CreateProxyFactory(); // copy our properties (proxyTargetClass) inherited from ProxyConfig proxyFactory.CopyFrom(this); object target = targetSource.GetTarget(); if (!ProxyTargetType) { // Must allow for introductions; can't just set interfaces to // the target's interfaces only. Type[] targetInterfaceTypes = AopUtils.GetAllInterfacesFromType(targetType); foreach (Type interfaceType in targetInterfaceTypes) { proxyFactory.AddInterface(interfaceType); } } IAdvisor[] advisors = BuildAdvisors(targetName, specificInterceptors); foreach (IAdvisor advisor in advisors) { if (advisor is IIntroductionAdvisor) { proxyFactory.AddIntroduction((IIntroductionAdvisor)advisor); } else { proxyFactory.AddAdvisor(advisor); } } proxyFactory.TargetSource = targetSource; CustomizeProxyFactory(proxyFactory); proxyFactory.IsFrozen = freezeProxy; return(proxyFactory.GetProxy()); }
public void GetAllInterfacesFromTypeWithNull() { AopUtils.GetAllInterfacesFromType(null); }
public void GetAllInterfacesFromTypeWithNull() { Assert.Throws <ArgumentNullException>(() => AopUtils.GetAllInterfacesFromType(null)); }