File tree 1 file changed +26
-0
lines changed
src/AzureOpenAIProxy.ApiApp/Extensions
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ using AzureOpenAIProxy . ApiApp . Configurations ;
2
+
3
+
4
+ namespace AzureOpenAIProxy . ApiApp . Extensions ;
5
+
6
+ /// <summary>
7
+ /// This represents the extension entity for the <see cref="StorageSettings"/> class.
8
+ /// </summary>
9
+ public static class StorageSettingsExtensions
10
+ {
11
+ /// <summary>
12
+ /// Gets the Storage configuration settings by reading appsettings.json.
13
+ /// </summary>
14
+ /// <param name="services"><see cref="IServiceCollection"/> instance.</param>
15
+ /// <returns>Returns <see cref="StorageSettings"/> instance.</returns>
16
+ public static StorageSettings GetStorageSettings ( this IServiceCollection services )
17
+ {
18
+ var configuration = services . BuildServiceProvider ( ) . GetService < IConfiguration > ( )
19
+ ?? throw new InvalidOperationException ( $ "{ nameof ( IConfiguration ) } service is not registered.") ;
20
+
21
+ var settings = configuration . GetSection ( StorageSettings . Name ) . Get < StorageSettings > ( )
22
+ ?? throw new InvalidOperationException ( $ "{ nameof ( StorageSettings ) } could not be retrieved from the configuration.") ;
23
+
24
+ return settings ;
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments