• CacheManager
  • Documentation
  • Api Docs
  • MichaCo.net
    Show / Hide Table of Contents

    Class ServiceCollectionExtensions

    Extensions to read cache manager configurations from ASP.NET Core configuration and add it to the DI framework.

    Inheritance
    Object
    ServiceCollectionExtensions
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace:Microsoft.Extensions.DependencyInjection
    Assembly:CacheManager.Microsoft.Extensions.Configuration.dll
    Syntax
    public static class ServiceCollectionExtensions

    Methods

    | Improve this Doc View Source

    AddCacheManager(IServiceCollection)

    Adds a singleton open generic service for ICacheManager<TCacheValue> to the Microsoft.Extensions.DependencyInjection.IServiceCollection.

    This requires one ICacheManagerConfiguration to be registered.

    Declaration
    public static IServiceCollection AddCacheManager(this IServiceCollection collection)
    Parameters
    Type Name Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection collection

    The services collection.

    Returns
    Type Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection

    The services collection.

    Remarks

    With this setup, you can inject ICacheManager<TCacheValue> with any kind ot T to your controllers and the DI framework will resolve a new singleton instance for each type.

    | Improve this Doc View Source

    AddCacheManager<T>(IServiceCollection, IConfiguration, String, Action<ConfigurationBuilder>)

    Adds a singleton service for ICacheManager<TCacheValue> for the specified T to the Microsoft.Extensions.DependencyInjection.IServiceCollection.

    This requires at least one ICacheManagerConfiguration to be registered. If more than one ICacheManagerConfigurations are registered, use configurationName to specify which one to use.

    Declaration
    public static IServiceCollection AddCacheManager<T>(this IServiceCollection collection, IConfiguration fromConfiguration, string configurationName = null, Action<ConfigurationBuilder> configure = null)
    Parameters
    Type Name Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection collection

    The services collection.

    Microsoft.Extensions.Configuration.IConfiguration fromConfiguration

    The Microsoft.Extensions.Configuration.IConfiguration section which contains a cacheManagers section.

    String configurationName

    The name of the ICacheManagerConfiguration to use.

    Action<ConfigurationBuilder> configure

    Can be used to further configure the ICacheManagerConfiguration.

    Returns
    Type Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection

    The services collection.

    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    AddCacheManager<T>(IServiceCollection, Action<ConfigurationBuilder>, String)

    Adds a singleton service for ICacheManager<TCacheValue> for the specified T to the Microsoft.Extensions.DependencyInjection.IServiceCollection using the inline configuration defined by configure.

    Declaration
    public static IServiceCollection AddCacheManager<T>(this IServiceCollection collection, Action<ConfigurationBuilder> configure, string name = null)
    Parameters
    Type Name Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection collection

    The services collection.

    Action<ConfigurationBuilder> configure

    Used to configure the instance of ICacheManager<TCacheValue>.

    String name

    The (optional) name for the ICacheManagerConfiguration.

    Returns
    Type Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection

    The services collection.

    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    AddCacheManagerConfiguration(IServiceCollection, IConfiguration)

    Adds one ICacheManagerConfiguration as singleton to the DI framework reading it from fromConfiguration. This overload will throw in case there are multiple cache manager configurations defined.

    Declaration
    public static IServiceCollection AddCacheManagerConfiguration(this IServiceCollection collection, IConfiguration fromConfiguration)
    Parameters
    Type Name Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection collection

    The services collection.

    Microsoft.Extensions.Configuration.IConfiguration fromConfiguration

    The Microsoft.Extensions.Configuration.IConfiguration section which contains a cacheManagers section.

    Returns
    Type Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection

    The services collection

    | Improve this Doc View Source

    AddCacheManagerConfiguration(IServiceCollection, IConfiguration, Action<ConfigurationBuilder>)

    Adds one ICacheManagerConfiguration as singleton to the DI framework reading it from fromConfiguration. This overload will throw in case there are multiple cache manager configurations defined.

    Declaration
    public static IServiceCollection AddCacheManagerConfiguration(this IServiceCollection collection, IConfiguration fromConfiguration, Action<ConfigurationBuilder> configure)
    Parameters
    Type Name Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection collection

    The services collection.

    Microsoft.Extensions.Configuration.IConfiguration fromConfiguration

    The Microsoft.Extensions.Configuration.IConfiguration section which contains a cacheManagers section.

    Action<ConfigurationBuilder> configure

    Can be used to further configure the configuration.

    Returns
    Type Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection

    The services collection

    | Improve this Doc View Source

    AddCacheManagerConfiguration(IServiceCollection, IConfiguration, String)

    Adds one named ICacheManagerConfiguration as singleton to the DI framework reading it from fromConfiguration.

    Declaration
    public static IServiceCollection AddCacheManagerConfiguration(this IServiceCollection collection, IConfiguration fromConfiguration, string name)
    Parameters
    Type Name Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection collection

    The services collection.

    Microsoft.Extensions.Configuration.IConfiguration fromConfiguration

    The Microsoft.Extensions.Configuration.IConfiguration section which contains a cacheManagers section.

    String name

    The name used in the configuration.

    Returns
    Type Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection

    The services collection

    | Improve this Doc View Source

    AddCacheManagerConfiguration(IServiceCollection, IConfiguration, String, Action<ConfigurationBuilder>)

    Adds one named ICacheManagerConfiguration as singleton to the DI framework reading it from fromConfiguration.

    Declaration
    public static IServiceCollection AddCacheManagerConfiguration(this IServiceCollection collection, IConfiguration fromConfiguration, string name, Action<ConfigurationBuilder> configure)
    Parameters
    Type Name Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection collection

    The services collection.

    Microsoft.Extensions.Configuration.IConfiguration fromConfiguration

    The Microsoft.Extensions.Configuration.IConfiguration section which contains a cacheManagers section.

    String name

    The name used in the configuration.

    Action<ConfigurationBuilder> configure

    Can be used to further configure the configuration.

    Returns
    Type Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection

    The services collection

    | Improve this Doc View Source

    AddCacheManagerConfiguration(IServiceCollection, Action<ConfigurationBuilder>, String)

    Adds a new ICacheManagerConfiguration as singleton to the DI framework.

    Declaration
    public static IServiceCollection AddCacheManagerConfiguration(this IServiceCollection collection, Action<ConfigurationBuilder> configure, string name = null)
    Parameters
    Type Name Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection collection

    The services collection.

    Action<ConfigurationBuilder> configure

    The ConfigurationBuilder used for defining the ICacheManagerConfiguration.

    String name

    The (optional) name to be used for the ICacheManagerConfiguration.

    Returns
    Type Description
    Microsoft.Extensions.DependencyInjection.IServiceCollection
    • Improve this Doc
    • View Source
    © 2025 by Michael Conrad. All rights reserved. - MichaCo.net