Exemple #1
0
        public static IServiceProvider BuildUrdAopServiceProvider(this IServiceCollection sc, IInterceptorGenerator[] interceptors, LoomOptions options = null)
        {
            var op = options ?? LoomOptions.CreateDefault();
            var userFilterProxy = op.FilterProxy ?? ((ITypeSymbolInfo i) => true);
            var userFilterForDefaultImplement = op.FilterForDefaultImplement ?? ((ITypeSymbolInfo i) => true);

            op.FilterProxy = i => i.Namespace != null && AopUtils.CanAopType(i) && userFilterProxy(i);
            op.FilterForDefaultImplement = i => i.Namespace != null && AopUtils.CanDoDefaultImplement(i) && userFilterForDefaultImplement(i);

            DestinyExtensions.CleanCache();
            GC.Collect();
            return(sc.BuildAopServiceProvider(null));
        }
Exemple #2
0
        public static IServiceProvider BuildVerthandiAopServiceProvider(this IServiceCollection sc, IInterceptorGenerator[] interceptors, LoomOptions options = null)
        {
            var op = options ?? LoomOptions.CreateDefault();
            var userFilterProxy = op.FilterProxy ?? ((ITypeSymbolInfo i) => true);
            var userFilterForDefaultImplement = op.FilterForDefaultImplement ?? ((ITypeSymbolInfo i) => true);

            op.FilterProxy = i => i.Namespace != null && AopUtils.CanAopType(i) && userFilterProxy(i);
            op.FilterForDefaultImplement = i => i.Namespace != null && AopUtils.CanDoDefaultImplement(i) && userFilterForDefaultImplement(i);
            var generator = new AopSourceGenerator(op, interceptors ?? new IInterceptorGenerator[0]);
            var types     = sc.Select(i => i.ServiceType).Select(j => j.IsGenericType ? j.GetGenericTypeDefinition() : j).Distinct().ToArray();
            var assembly  = generator.Generate(new TypesSymbolSource(types));

            DestinyExtensions.CleanCache();
            GC.Collect();
            return(sc.BuildAopServiceProvider(assembly));
        }