You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking for the 'correct' way to replace the .WithScopedLifetime() call to be conditional by inspecting each matching type for an attribute where I can indicate the lifetime to use and if that attribute is not present, use a default instead.
I've looked into [ServiceDescriptorAttribute] but it has a 1st argument of Type which I don't really want to alter the behavior and want it to remain based on the calls from the scan fluent chain (.AsSelfWithInterfaces() from above). I only want to alter the lifetime that is used AND to not require this attribute to be present and when not present apply a default lifetime.
I'd also like to be able to use "my attributes" versus tightly coupling all my components to Scrutor directly but that's just a preference.
I know there's the .WithLifetime(..) option and I could provide my own function but what I don't have is a way to inspect each type in that method as it doesn't use a Func<Type, Lifetime> to support that approach.
So given the current version, what's the best option to achieve this goal? As for any feature request to support this, it seems like if WithLifetime(..) would accept that function to support inspecting each type that would get me very close to my goal and not require me decorating all my code with Scrutor specific attributes.
The text was updated successfully, but these errors were encountered:
Currently we're using Scrutor to scan & register a set of components and use the approach below:
I'm looking for the 'correct' way to replace the .WithScopedLifetime() call to be conditional by inspecting each matching type for an attribute where I can indicate the lifetime to use and if that attribute is not present, use a default instead.
I've looked into [ServiceDescriptorAttribute] but it has a 1st argument of Type which I don't really want to alter the behavior and want it to remain based on the calls from the scan fluent chain (.AsSelfWithInterfaces() from above). I only want to alter the lifetime that is used AND to not require this attribute to be present and when not present apply a default lifetime.
I'd also like to be able to use "my attributes" versus tightly coupling all my components to Scrutor directly but that's just a preference.
I know there's the .WithLifetime(..) option and I could provide my own function but what I don't have is a way to inspect each type in that method as it doesn't use a Func<Type, Lifetime> to support that approach.
So given the current version, what's the best option to achieve this goal? As for any feature request to support this, it seems like if WithLifetime(..) would accept that function to support inspecting each type that would get me very close to my goal and not require me decorating all my code with Scrutor specific attributes.
The text was updated successfully, but these errors were encountered: