/// <summary> /// For registering middleware that is resolved from Windsor /// </summary> /// <typeparam name="T">A generic type that implements <see cref="IMiddleware"/></typeparam> /// <param name="registration"><see cref="ComponentRegistration{T}"/></param> /// <returns><see cref="ComponentRegistration{T}"/></returns> public static ComponentRegistration <T> AsMiddleware <T>(this ComponentRegistration <T> registration) where T : class, IMiddleware { registration.Attribute(AspNetCoreFacility.IsRegisteredAsMiddlewareIntoApplicationBuilderKey).Eq(Boolean.TrueString); return(registration); }
/// <summary> /// Returns new instances everytime it's resolved but disposes it on <see name="IServiceScope" /> end /// </summary> /// <typeparam name="TService">Service type</typeparam> public static ComponentRegistration <TService> LifestyleNetTransient <TService>(this ComponentRegistration <TService> registration) where TService : class { return(registration .Attribute(ExtensionContainerScope.TransientMarker).Eq(Boolean.TrueString) .LifeStyle.ScopedToNetServiceScope()); //.NET core expects new instances but release on scope dispose }
/// <summary> /// For making types available to the <see cref="IServiceCollection"/> using 'late bound' factories which resolve from Windsor. This makes things like the @Inject directive in Razor work. /// </summary> /// <param name="registration">The component registration that gets copied across to the IServiceCollection</param> public static ComponentRegistration <T> CrossWired <T>(this ComponentRegistration <T> registration) where T : class { registration.Attribute(AspNetCoreFacility.IsCrossWiredIntoServiceCollectionKey).Eq(Boolean.TrueString); return(registration); }