Class MicrosoftConfigurationExtensions
Extensions for the Microsoft configuration framework to load CacheManagerConfigurations.
Inherited Members
Namespace:Microsoft.Extensions.Configuration
Assembly:CacheManager.Microsoft.Extensions.Configuration.dll
Syntax
public static class MicrosoftConfigurationExtensions
Methods
| Improve this Doc View SourceGetCacheConfiguration(IConfiguration)
Gets the first and only CacheManagerConfiguration defined in the
cacheManagers section of the provided configuration.
Declaration
public static ICacheManagerConfiguration GetCacheConfiguration(this IConfiguration configuration)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.Extensions.Configuration.IConfiguration | configuration | The source configuration. |
Returns
| Type | Description |
|---|---|
| ICacheManagerConfiguration | The |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | If no cacheManagers section is defined or more than one manager is configured. |
GetCacheConfiguration(IConfiguration, String)
Retrieve a CacheManagerConfiguration defined in the
cacheManagers section of the provided configuration by name.
Declaration
public static ICacheManagerConfiguration GetCacheConfiguration(this IConfiguration configuration, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.Extensions.Configuration.IConfiguration | configuration | The source configuration. |
| String | name | The name of the cache. |
Returns
| Type | Description |
|---|---|
| ICacheManagerConfiguration |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If either configuration or name is null. |
| InvalidOperationException | If no section is defined in the configuration,
or if no configuration was found for the name.
|
GetCacheConfigurations(IConfiguration)
Retrieves all configured CacheManagerConfigurations defined in the
cacheManagers section of the provided configuration.
Declaration
public static IEnumerable<ICacheManagerConfiguration> GetCacheConfigurations(this IConfiguration configuration)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.Extensions.Configuration.IConfiguration | configuration | The source configuration. |
Returns
| Type | Description |
|---|---|
| IEnumerable<ICacheManagerConfiguration> | The list of ICacheManagerConfigurations. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | If no section is defined.
|
LoadRedisConfigurations(IConfiguration)
Loads all available Redis configurations from the the
redis section of the provided configuration.
Declaration
public static void LoadRedisConfigurations(this IConfiguration configuration)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.Extensions.Configuration.IConfiguration | configuration | The source configuration. |
Remarks
This method always gets invoked by GetCacheConfiguration(IConfiguration) or the other overloads. You do not have to call this explicitly. The method also does not throw an exception if the
redis section is
not defined.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | If the CacheManager.StackExchange.Redis package is not installed. |