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); } }
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))); }
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); } } }