Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xml comments to IAppCache, CachingService and DI extension methods #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion LazyCache.AspNetCore/LazyCacheServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@
// ReSharper disable once CheckNamespace - MS guidelines say put DI registration in this NS
namespace Microsoft.Extensions.DependencyInjection
{
// See https://github.com/dotnet/runtime/blob/master/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCacheServiceCollectionExtensions.cs
// See https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCacheServiceCollectionExtensions.cs
/// <summary>
/// Set of extensions for registering LazyCache dependencies with <see cref="IServiceCollection"/> instance.
/// </summary>
public static class LazyCacheServiceCollectionExtensions
{
/// <summary>
/// Register a non distributed in memory implementation of <see cref="IAppCache"/>.
/// </summary>
/// <remarks>
/// For implementation details see <see cref="CachingService"/>
/// </remarks>
/// <param name="services">Instance of <see cref="IServiceCollection"/>.</param>
/// <returns>Modified instance of <see cref="IServiceCollection"/>.</returns>
/// <exception cref="ArgumentNullException"></exception>
public static IServiceCollection AddLazyCache(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
Expand All @@ -25,6 +37,13 @@ public static IServiceCollection AddLazyCache(this IServiceCollection services)
return services;
}

/// <summary>
/// Register a custom implementation of <see cref="IAppCache"/> to the
/// </summary>
/// <param name="services">Instance of <see cref="IServiceCollection"/>.</param>
/// <param name="implementationFactory">A delegate that allows users to inject their own <see cref="IAppCache"/> implementation.</param>
/// <returns>Modified instance of <see cref="IServiceCollection"/.></returns>
/// <exception cref="ArgumentNullException">Thrown when any of: <paramref name="services"/> or <paramref name="implementationFactory"/> are null.</exception>
public static IServiceCollection AddLazyCache(this IServiceCollection services,
Func<IServiceProvider, CachingService> implementationFactory)
{
Expand Down
18 changes: 17 additions & 1 deletion LazyCache.Ninject/LazyCacheModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,36 @@

namespace LazyCache
{
// See https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCacheServiceCollectionExtensions.cs
/// <summary>
/// Set of extensions for registering LazyCache dependencies with <see cref="IServiceCollection"/> instance.
/// </summary>
public class LazyCacheModule : NinjectModule
{
private readonly Func<IAppCache> implementationFactory;

/// <summary>
/// Initializes new instance of <see cref="LazyCacheModule"/>.
/// </summary>
/// <remarks>
/// For implementation details see <see cref="CachingService"/>
/// </remarks>
public LazyCacheModule()
{
}

/// <summary>
/// Initializes new instance of <see cref="LazyCacheModule"/>.
/// </summary>
/// <param name="implementationFactory">A delegate that allows users to inject their own <see cref="IAppCache"/> implementation.</param>
public LazyCacheModule(Func<IAppCache> implementationFactory)
{
this.implementationFactory = implementationFactory;
}

// See also https://github.com/aspnet/Caching/blob/dev/src/Microsoft.Extensions.Caching.Memory/MemoryCacheServiceCollectionExtensions.cs
/// <summary>
/// Overrides <see cref="NinjectModule.Load"/> and registers LazyeCache dependencies.
/// </summary>
public override void Load()
{
Bind<IOptions<MemoryCacheOptions>>().ToConstant(Options.Create(new MemoryCacheOptions()));
Expand Down
Loading