Beispiel #1
0
 public static void Intercept <TInterceptor>(this IRegistrator registrator, Func <Type, bool> predicate)
     where TInterceptor : class, IInterceptor
 {
     foreach (var registration in registrator.GetServiceRegistrations().Where(r => predicate(r.ServiceType)))
     {
         registrator.Intercept <TInterceptor>(registration.ServiceType);
     }
 }
Beispiel #2
0
 private static IEnumerable <Type> DiscoverRegisteredMiddlewares(this IRegistrator registry)
 {
     return(registry.GetServiceRegistrations()
            .Where(r => r.ServiceType.IsAssignableTo(typeof(OwinMiddleware)))
            // note: ordering is important and set to registration order by default
            .OrderBy(r => r.FactoryRegistrationOrder)
            .Select(r => typeof(DryIocWrapperMiddleware <>)
                    .MakeGenericType(r.Factory.ImplementationType ?? r.ServiceType)));
 }
Beispiel #3
0
        private static void UseRegisteredMiddlewares(this IAppBuilder app, IRegistrator registry)
        {
            var services = registry.GetServiceRegistrations()
                           .Where(r => r.ServiceType.IsAssignableTo(typeof(OwinMiddleware)))
                           // note: ordering is important and set to registration order by default
                           .OrderBy(r => r.FactoryRegistrationOrder)
                           .Select(r => typeof(DryIocWrapperMiddleware <>)
                                   .MakeGenericType(r.Factory.ImplementationType ?? r.ServiceType));

            foreach (var service in services)
            {
                app.Use(service);
            }
        }
        private static void UseRegisteredMiddlewares(this IAppBuilder app, IRegistrator registry)
        {
            var services = registry.GetServiceRegistrations()
                           .Where(r => r.ServiceType.IsAssignableTo(typeof(OwinMiddleware)))
                           .Select(r => typeof(DryIocWrapperMiddleware <>)
                                   .MakeGenericType(r.Factory.ImplementationType ?? r.ServiceType))
                           .ToArray();

            if (!services.IsNullOrEmpty())
            {
                foreach (var service in services)
                {
                    app.Use(service);
                }
            }
        }