-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from dotnetcore/dev
Feature/Configuration
- Loading branch information
Showing
60 changed files
with
1,555 additions
and
169 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<EasyCachingCorePackageVersion>0.4.2</EasyCachingCorePackageVersion> | ||
<EasyCachingMemcachedPackageVersion>0.4.2</EasyCachingMemcachedPackageVersion> | ||
<EasyCachingRedisPackageVersion>0.4.2</EasyCachingRedisPackageVersion> | ||
<EasyCachingSQLitePackageVersion>0.4.2</EasyCachingSQLitePackageVersion> | ||
<EasyCachingInMemoryPackageVersion>0.4.3</EasyCachingInMemoryPackageVersion> | ||
<EasyCachingHybridPackageVersion>0.4.2</EasyCachingHybridPackageVersion> | ||
<EasyCachingCorePackageVersion>0.4.5</EasyCachingCorePackageVersion> | ||
<EasyCachingMemcachedPackageVersion>0.4.5</EasyCachingMemcachedPackageVersion> | ||
<EasyCachingRedisPackageVersion>0.4.5</EasyCachingRedisPackageVersion> | ||
<EasyCachingSQLitePackageVersion>0.4.5</EasyCachingSQLitePackageVersion> | ||
<EasyCachingInMemoryPackageVersion>0.4.5</EasyCachingInMemoryPackageVersion> | ||
<EasyCachingHybridPackageVersion>0.4.5</EasyCachingHybridPackageVersion> | ||
<EasyCachingAspectCorePackageVersion>0.3.2</EasyCachingAspectCorePackageVersion> | ||
<EasyCachingCastlePackageVersion>0.3.2</EasyCachingCastlePackageVersion> | ||
<EasyCachingResponseCachingPackageVersion>0.3.0</EasyCachingResponseCachingPackageVersion> | ||
<EasyCachingJsonPackageVersion>0.3.1</EasyCachingJsonPackageVersion> | ||
<EasyCachingMessagePackPackageVersion>0.3.0</EasyCachingMessagePackPackageVersion> | ||
<EasyCachingProtobufPackageVersion>0.3.0</EasyCachingProtobufPackageVersion> | ||
<EasyCachingJsonPackageVersion>0.3.5</EasyCachingJsonPackageVersion> | ||
<EasyCachingMessagePackPackageVersion>0.3.5</EasyCachingMessagePackPackageVersion> | ||
<EasyCachingProtobufPackageVersion>0.3.5</EasyCachingProtobufPackageVersion> | ||
</PropertyGroup> | ||
</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
33 changes: 33 additions & 0 deletions
33
src/EasyCaching.Core/Configurations/EasyCachingApplicationBuliderExtensions.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,33 @@ | ||
namespace EasyCaching.Core | ||
{ | ||
using Microsoft.AspNetCore.Builder; | ||
using System; | ||
|
||
public static class EasyCachingApplicationBuliderExtensions | ||
{ | ||
/// <summary> | ||
/// Uses the easy caching. | ||
/// </summary> | ||
/// <returns>The easy caching.</returns> | ||
/// <param name="app">App.</param> | ||
public static IApplicationBuilder UseEasyCaching(this IApplicationBuilder app) | ||
{ | ||
if (app == null) | ||
{ | ||
throw new ArgumentNullException(nameof(app)); | ||
} | ||
|
||
var options = app.ApplicationServices.GetService(typeof(EasyCachingOptions)); | ||
|
||
if (options != null && options is EasyCachingOptions) | ||
{ | ||
foreach (var serviceExtension in ((EasyCachingOptions)options).Extensions) | ||
{ | ||
serviceExtension.WithServices(app); | ||
} | ||
} | ||
|
||
return app; | ||
} | ||
} | ||
} |
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,35 @@ | ||
namespace EasyCaching.Core | ||
{ | ||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// EasyCaching options. | ||
/// </summary> | ||
public class EasyCachingOptions | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="T:EasyCaching.Core.EasyCachingOptions"/> class. | ||
/// </summary> | ||
public EasyCachingOptions() | ||
{ | ||
Extensions = new List<IEasyCachingOptionsExtension>(); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the extensions. | ||
/// </summary> | ||
/// <value>The extensions.</value> | ||
internal IList<IEasyCachingOptionsExtension> Extensions { get; } | ||
|
||
/// <summary> | ||
/// Registers the extension. | ||
/// </summary> | ||
/// <param name="extension">Extension.</param> | ||
public void RegisterExtension(IEasyCachingOptionsExtension extension) | ||
{ | ||
Internal.ArgumentCheck.NotNull(extension, nameof(extension)); | ||
|
||
Extensions.Add(extension); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/EasyCaching.Core/Configurations/EasyCachingServiceCollectionExtensions.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,36 @@ | ||
namespace EasyCaching.Core | ||
{ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
|
||
/// <summary> | ||
/// EasyCaching service collection extensions. | ||
/// </summary> | ||
public static class EasyCachingServiceCollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Adds the easycaching. | ||
/// </summary> | ||
/// <returns>The easy caching.</returns> | ||
/// <param name="services">Services.</param> | ||
/// <param name="setupAction">Setup action.</param> | ||
public static IServiceCollection AddEasyCaching(this IServiceCollection services, Action<EasyCachingOptions> setupAction) | ||
{ | ||
if (setupAction == null) | ||
{ | ||
throw new ArgumentNullException(nameof(setupAction)); | ||
} | ||
|
||
//Options and extension service | ||
var options = new EasyCachingOptions(); | ||
setupAction(options); | ||
foreach (var serviceExtension in options.Extensions) | ||
{ | ||
serviceExtension.AddServices(services); | ||
} | ||
services.AddSingleton(options); | ||
|
||
return services; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/EasyCaching.Core/Configurations/IEasyCachingOptionsExtension.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,23 @@ | ||
namespace EasyCaching.Core | ||
{ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
/// <summary> | ||
/// EasyCaching options extension. | ||
/// </summary> | ||
public interface IEasyCachingOptionsExtension | ||
{ | ||
/// <summary> | ||
/// Adds the services. | ||
/// </summary> | ||
/// <param name="services">Services.</param> | ||
void AddServices(IServiceCollection services); | ||
|
||
/// <summary> | ||
/// Withs the services. | ||
/// </summary> | ||
/// <param name="app">App.</param> | ||
void WithServices(IApplicationBuilder app); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/EasyCaching.HybridCache/Configurations/EasyCachingOptionsExtensions.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,22 @@ | ||
namespace EasyCaching.HybridCache | ||
{ | ||
using EasyCaching.Core; | ||
|
||
/// <summary> | ||
/// EasyCaching options extensions. | ||
/// </summary> | ||
public static class EasyCachingOptionsExtensions | ||
{ | ||
/// <summary> | ||
/// Uses the hybrid. | ||
/// </summary> | ||
/// <returns>The hybrid.</returns> | ||
/// <param name="options">Options.</param> | ||
public static EasyCachingOptions UseHybrid(this EasyCachingOptions options) | ||
{ | ||
options.RegisterExtension(new HybridCacheOptionsExtension()); | ||
|
||
return options; | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/EasyCaching.HybridCache/Configurations/HybridCacheOptionsExtension.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,31 @@ | ||
namespace EasyCaching.HybridCache | ||
{ | ||
using EasyCaching.Core; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
|
||
/// <summary> | ||
/// HybridCache options extension. | ||
/// </summary> | ||
internal sealed class HybridCacheOptionsExtension : IEasyCachingOptionsExtension | ||
{ | ||
/// <summary> | ||
/// Adds the services. | ||
/// </summary> | ||
/// <param name="services">Services.</param> | ||
public void AddServices(IServiceCollection services) | ||
{ | ||
services.TryAddSingleton<IHybridCachingProvider, HybridCachingProvider>(); | ||
} | ||
|
||
/// <summary> | ||
/// Withs the services. | ||
/// </summary> | ||
/// <param name="services">Services.</param> | ||
public void WithServices(IApplicationBuilder services) | ||
{ | ||
// Method intentionally left empty. | ||
} | ||
} | ||
} |
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
Oops, something went wrong.