protected override bool ShouldRegisterService(Type type, AppBlocksServiceBaseAttribute serviceAttribute) { if (type.FullName == "AppBlocks.Autofac.Tests.RegistrationFilter.TestFilteredOutService") { return(false); } return(base.ShouldRegisterService(type, serviceAttribute)); }
/// <summary> /// Sets service lifetime scope /// </summary> private static void SetTypeLifetimeScope( AppBlocksServiceBaseAttribute attribute, IRegistrationBuilder <object, ConcreteReflectionActivatorData, SingleRegistrationStyle> registration) { //Service is available as all implemented interfaces. switch (attribute.ServiceScope) { // Register as single instance case AppBlocksInstanceLifetime.SingleInstance: registration.SingleInstance(); break; // Register with instance for each depedency case AppBlocksInstanceLifetime.InstancePerDependency: registration.InstancePerDependency(); break; // Register with instance per lifetime scope case AppBlocksInstanceLifetime.InstancePerLifetimeScope: registration.InstancePerLifetimeScope(); break; } }
/// <summary> /// Override to prevent certain services from being registered. This may be useful while running /// tests when you want to mock certain services and prevent the live service from being registered /// </summary> /// <param name="type"><see cref="Type"/> for service being registered</param> /// <param name="serviceAttribute"><see cref="AppBlocksServiceAttribute"/> on the service</param> /// <returns><c>true</c> if you want service to be registered; otherwise <c>false</c>.</returns> protected internal virtual bool ShouldRegisterService(Type type, AppBlocksServiceBaseAttribute serviceAttribute) => true;