0
yasin.hallak.89@gmail.com created
- ABP Framework version: v6.0.0
- UI type: MVC
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no
Hi there ...
I need to inject service in static class. Is there any way in abp to do this please :)
5 Answer(s)
-
0
hi
Can you share your static class?
-
0
hi
Can you share your static class?
public static class AssignmentExtensions { public static string AssignmentTypeHelper(this Assignment target, IStringLocalizer localize) { string assignmentType = string.Empty; if (target.IsTemporary) { if (target.IsGuard()) assignmentType = $"{localize["Guard"]} - {localize["General.Temporary"]}"; if (target.IsReservedGuard()) assignmentType = $"{localize["ReservedGuard"]} - {localize["General.Temporary"]}"; if (target.IsFieldSupervisor()) { assignmentType = $"{localize["FieldSupervisor"]} - {localize["General.Temporary"]}"; } } else { assignmentType = $"{localize["Guard"]} - {localize["General.Permanently"]}"; } return assignmentType; } }
-
0
You can consider passing services or
IServiceProvider
to static method. -
0
You can consider passing services or
IServiceProvider
to static method.This method deep nested , I need to pass IServiceProvider to all methods !.
I need efficient way more than this
-
1
This is not related to ABP but the language itself. Check How to inject dependency to static class.