-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtility.cs
More file actions
27 lines (20 loc) · 744 Bytes
/
Utility.cs
File metadata and controls
27 lines (20 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using Microsoft.Extensions.DependencyInjection;
namespace ClifferBasic;
internal static class Utility {
private static IServiceProvider? _serviceProvider;
internal static void SetServiceProvider(IServiceProvider provider) {
_serviceProvider = provider;
}
internal static IServiceProvider GetServiceProvider() {
if (_serviceProvider is null) {
throw new InvalidOperationException("Service provider is not set.");
}
return _serviceProvider;
}
internal static T? GetService<T>() {
if (_serviceProvider is null) {
throw new InvalidOperationException("Service provider is not set.");
}
return _serviceProvider.GetService<T>();
}
}