diff --git a/src/SteroidsDI.Tests/Cases.Approval/SteroidsDI.approved.txt b/src/SteroidsDI.Tests/Cases.Approval/SteroidsDI.approved.txt index 0deb089..1471820 100644 --- a/src/SteroidsDI.Tests/Cases.Approval/SteroidsDI.approved.txt +++ b/src/SteroidsDI.Tests/Cases.Approval/SteroidsDI.approved.txt @@ -21,11 +21,11 @@ namespace SteroidsDI public Microsoft.Extensions.DependencyInjection.IServiceCollection Services { get; } public SteroidsDI.BindingContext Default() where TImplementation : TService { } - public SteroidsDI.BindingContext Default(Microsoft.Extensions.DependencyInjection.ServiceLifetime lifetime = 2) + public SteroidsDI.BindingContext Default(Microsoft.Extensions.DependencyInjection.ServiceLifetime lifetime) where TImplementation : TService { } public SteroidsDI.BindingContext Named(object name) where TImplementation : TService { } - public SteroidsDI.BindingContext Named(object name, Microsoft.Extensions.DependencyInjection.ServiceLifetime lifetime = 2) + public SteroidsDI.BindingContext Named(object name, Microsoft.Extensions.DependencyInjection.ServiceLifetime lifetime) where TImplementation : TService { } } public sealed class GenericScopeProvider : SteroidsDI.Core.IScopeProvider diff --git a/src/SteroidsDI/Factory/BindingContext.cs b/src/SteroidsDI/Factory/BindingContext.cs index 2251c10..6820e26 100644 --- a/src/SteroidsDI/Factory/BindingContext.cs +++ b/src/SteroidsDI/Factory/BindingContext.cs @@ -33,7 +33,7 @@ public BindingContext(IServiceCollection services) /// /// The lifetime of the dependency object. /// Reference to this to be able to call methods in a chain. - public BindingContext Named(object name, ServiceLifetime lifetime = ServiceLifetime.Transient) + public BindingContext Named(object name, ServiceLifetime lifetime) where TImplementation : TService { if (name == null) @@ -77,7 +77,7 @@ public BindingContext Named(object name) /// Implementation type. /// The lifetime of the dependency object. /// Reference to this to be able to call methods in a chain. - public BindingContext Default(ServiceLifetime lifetime = ServiceLifetime.Transient) + public BindingContext Default(ServiceLifetime lifetime) where TImplementation : TService { var existing = Services.SingleOrDefault(descriptor => descriptor.ServiceType == typeof(TImplementation));