| | |
| | | if (HttpContext?.RequestServices != null) |
| | | return HttpContext.RequestServices; |
| | | |
| | | if (App.RootServices != null) |
| | | if (RootServices != null) |
| | | { |
| | | IServiceScope scope = RootServices.CreateScope(); |
| | | return scope.ServiceProvider; |
| | |
| | | |
| | | public static TService GetService<TService>(bool mustBuild = true) where TService : class |
| | | { |
| | | TService test = App.GetService(typeof(TService), null, mustBuild) as TService; |
| | | TService test = GetService(typeof(TService), null, mustBuild) as TService; |
| | | return test; |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | public static object GetService(Type type, IServiceProvider serviceProvider = null, bool mustBuild = true) |
| | | { |
| | | object obj = (serviceProvider ?? App.GetServiceProvider(type, mustBuild, false))?.GetService(type); |
| | | object obj = (serviceProvider ?? GetServiceProvider(type, mustBuild, false))?.GetService(type); |
| | | return obj; |
| | | } |
| | | |