forked from alastairtree/LazyCache
-
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.
feat: add LazyCache.AspNetCore DI pkg
- Loading branch information
1 parent
8aab626
commit 45648a6
Showing
5 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
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
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
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,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<RootNamespace>LazyCache</RootNamespace> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Version>2.0.0</Version> | ||
<Authors>https://github.com/alastairtree</Authors> | ||
<Company>https://github.com/alastairtree</Company> | ||
<Description>ServiceCollection regististrations fopr LazyCache to initialise the depndency injection</Description> | ||
<Copyright>Copyright 2014 - 2018 Alastair Crabtree</Copyright> | ||
<PackageLicenseUrl>https://github.com/alastairtree/LazyCache/blob/master/LICENSE</PackageLicenseUrl> | ||
<PackageProjectUrl>https://github.com/alastairtree/LazyCache</PackageProjectUrl> | ||
<PackageIconUrl>https://raw.githubusercontent.com/alastairtree/LazyCache/master/artwork/logo-128.png</PackageIconUrl> | ||
<RepositoryUrl>https://github.com/alastairtree/LazyCache</RepositoryUrl> | ||
<PackageTags>LazyCache DependecyInjection ServiceCollection SingleTon Transient</PackageTags> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="microsoft.extensions.dependencyinjection.abstractions" Version="2.0.0" /> | ||
<ProjectReference Include="..\LazyCache\LazyCache.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,28 @@ | ||
using System; | ||
using LazyCache; | ||
|
||
// ReSharper disable once CheckNamespace - MS guidelines say put DI registration in this NS | ||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
public static class LazyCacheServiceRegistration | ||
{ | ||
public static IServiceCollection AddLazyCache(this IServiceCollection services) | ||
{ | ||
if (services == null) throw new ArgumentNullException(nameof(services)); | ||
|
||
services.AddSingleton<IAppCache, CachingService>(); | ||
|
||
return services; | ||
} | ||
|
||
public static IServiceCollection AddLazyCache(this IServiceCollection services, Func<IServiceProvider, CachingService> implmentationFactory) | ||
{ | ||
if (services == null) throw new ArgumentNullException(nameof(services)); | ||
if (implmentationFactory == null) throw new ArgumentNullException(nameof(implmentationFactory)); | ||
|
||
services.AddSingleton<IAppCache>(implmentationFactory); | ||
|
||
return services; | ||
} | ||
} | ||
} |
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