forked from aliencube/azure-openai-sdk-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related to: aliencube#319
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/AzureOpenAIProxy.ApiApp/Extensions/StorageSettingsExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using AzureOpenAIProxy.ApiApp.Configurations; | ||
|
||
|
||
namespace AzureOpenAIProxy.ApiApp.Extensions; | ||
|
||
/// <summary> | ||
/// This represents the extension entity for the <see cref="StorageSettings"/> class. | ||
/// </summary> | ||
public static class StorageSettingsExtensions | ||
{ | ||
/// <summary> | ||
/// Gets the Storage configuration settings by reading appsettings.json. | ||
/// </summary> | ||
/// <param name="services"><see cref="IServiceCollection"/> instance.</param> | ||
/// <returns>Returns <see cref="StorageSettings"/> instance.</returns> | ||
public static StorageSettings GetStorageSettings(this IServiceCollection services) | ||
{ | ||
var configuration = services.BuildServiceProvider().GetService<IConfiguration>() | ||
?? throw new InvalidOperationException($"{nameof(IConfiguration)} service is not registered."); | ||
|
||
var settings = configuration.GetSection(StorageSettings.Name).Get<StorageSettings>() | ||
?? throw new InvalidOperationException($"{nameof(StorageSettings)} could not be retrieved from the configuration."); | ||
|
||
return settings; | ||
} | ||
} |