/// <summary> /// Creates an interface wrapper proxy type /// </summary> /// <param name="type">Type to proxify</param> /// <returns>The proxy type</returns> public Type CreateWrapperType(Type type) { lock (wrapperLookup.SyncRoot) { Type wrapperType = null; //incase a proxy for this type does not exist , generate it if (wrapperLookup[type] == null) { IList typeAspects = AspectMatcher.MatchAspectsForType(type, Configuration.Aspects); IList typeMixins = GetMixinsForType(type, typeAspects); typeMixins.Add(typeof(AopProxyMixin)); wrapperType = InterfaceProxyFactory.CreateProxyType(type, typeAspects, typeMixins, this); if (wrapperType == null) { throw new NullReferenceException( string.Format("Could not generate wrapper for type '{0}'", type.FullName)); } wrapperLookup[type] = wrapperType; string message = string.Format("Emitting new wrapper type for type {0}", type.FullName); LogManager.Info(this, message, ""); } else { //fetch the proxy type from the lookup wrapperType = wrapperLookup[type] as Type; string message = string.Format("Fetching proxy wrapper from cache for type {0}", type.FullName); LogManager.Info(this, message, ""); } return(wrapperType); } }
/// <summary> /// Creates a proxy type of a given type. /// </summary> /// <param name="baseType">Type to proxyfy</param> /// <param name="aspects">Untyped list of <c>IAspects</c> to apply to the proxy.</param> /// <param name="mixins">Untyped list of <c>System.Type</c>s that will be mixed in.</param> /// <param name="engine">The AopEngine requesting the proxy type</param> /// <returns></returns> public static Type CreateProxyType(Type baseType, IList aspects, IList mixins, Engine engine) { if (aspects.Count == 0 && mixins.Count == 1 && !AopTools.HasFixedAttributes(baseType)) return baseType; InterfaceProxyFactory factory = new InterfaceProxyFactory(engine); return factory.CreateType(baseType, aspects, mixins); }
/// <summary> /// Creates a proxy type of a given type. /// </summary> /// <param name="baseType">Type to proxyfy</param> /// <param name="aspects">Untyped list of <c>IAspects</c> to apply to the proxy.</param> /// <param name="mixins">Untyped list of <c>System.Type</c>s that will be mixed in.</param> /// <param name="engine">The AopEngine requesting the proxy type</param> /// <returns></returns> public static Type CreateProxyType(Type baseType, IList aspects, IList mixins, Engine engine) { if (aspects.Count == 0 && mixins.Count == 1) return baseType; InterfaceProxyFactory factory = new InterfaceProxyFactory(engine); return factory.CreateType(baseType, aspects, mixins); }
/// <summary> /// Creates a proxy type of a given type. /// </summary> /// <param name="baseType">Type to proxyfy</param> /// <param name="aspects">Untyped list of <c>IAspects</c> to apply to the proxy.</param> /// <param name="mixins">Untyped list of <c>System.Type</c>s that will be mixed in.</param> /// <param name="engine">The AopEngine requesting the proxy type</param> /// <returns></returns> public static Type CreateProxyType(Type baseType, IList aspects, IList mixins, Engine engine) { if (aspects.Count == 0 && mixins.Count == 1) { return(baseType); } InterfaceProxyFactory factory = new InterfaceProxyFactory(engine); return(factory.CreateType(baseType, aspects, mixins)); }