diff --git a/Examples/Caching/Examples.Caching.MemoryCaching/ConfigurationContainer.cs b/Examples/Caching/Examples.Caching.MemoryCaching/ConfigurationContainer.cs
new file mode 100644
index 00000000..78baccdc
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.MemoryCaching/ConfigurationContainer.cs
@@ -0,0 +1,14 @@
+using Microsoft.Extensions.Configuration;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Examples.Caching.MemoryCaching
+{
+ internal static class ConfigurationContainer
+ {
+ public static IConfiguration Configuration { get; set; }
+ }
+}
diff --git a/Examples/Caching/Examples.Caching.MemoryCaching/Examples.Caching.MemoryCaching.csproj b/Examples/Caching/Examples.Caching.MemoryCaching/Examples.Caching.MemoryCaching.csproj
new file mode 100644
index 00000000..b0ee9074
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.MemoryCaching/Examples.Caching.MemoryCaching.csproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Examples/Caching/Examples.Caching.MemoryCaching/Program.cs b/Examples/Caching/Examples.Caching.MemoryCaching/Program.cs
new file mode 100644
index 00000000..ad3497ea
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.MemoryCaching/Program.cs
@@ -0,0 +1,52 @@
+using Examples.Caching.MemoryCaching;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using RCommon;
+using RCommon.Caching;
+using RCommon.MemoryCache;
+using System.Diagnostics;
+using System.Reflection;
+
+try
+{
+ var host = Host.CreateDefaultBuilder(args)
+ .ConfigureAppConfiguration((context, builder) =>
+ {
+
+ ConfigurationContainer.Configuration = builder
+ .Build();
+ })
+ .ConfigureServices(services =>
+ {
+ // Configure RCommon
+ services.AddRCommon()
+ .WithCaching(cache =>
+ {
+
+ // Or this way which uses a little magic but is simple
+ cqrs.AddCommandHandlers((typeof(Program).GetTypeInfo().Assembly));
+ cqrs.AddQueryHandlers((typeof(Program).GetTypeInfo().Assembly));
+ });
+
+ services.AddTransient();
+
+ }).Build();
+
+ Console.WriteLine("Example Starting");
+ var appService = host.Services.GetRequiredService();
+ var commandResult = await appService(new TestCommand("test"));
+ var queryResult = await appService.ExecuteTestQuery(new TestQuery());
+
+ Console.WriteLine(commandResult.ToString());
+ Console.WriteLine(queryResult.Message);
+
+ Console.WriteLine("Example Complete");
+ Console.ReadLine();
+}
+catch (Exception ex)
+{
+ Console.WriteLine(ex.ToString());
+
+}
+
diff --git a/Examples/Caching/Examples.Caching.MemoryCaching/TestApplicationService.cs b/Examples/Caching/Examples.Caching.MemoryCaching/TestApplicationService.cs
new file mode 100644
index 00000000..07e1c101
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.MemoryCaching/TestApplicationService.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Examples.Caching.MemoryCaching
+{
+ public class TestApplicationService
+ {
+
+ public TestApplicationService()
+ {
+
+ }
+
+ public async Task SetCache()
+ {
+
+ }
+
+ public async Task GetCache()
+ {
+
+ }
+ }
+}
diff --git a/Examples/Caching/Examples.Caching.MemoryCaching/TestDto.cs b/Examples/Caching/Examples.Caching.MemoryCaching/TestDto.cs
new file mode 100644
index 00000000..ddec0def
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.MemoryCaching/TestDto.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Examples.Caching.MemoryCaching
+{
+ public record TestDto
+ {
+ public TestDto(string message)
+ {
+ Message = message;
+ }
+
+ public string Message { get; }
+ }
+}
diff --git a/Examples/Caching/Examples.Caching.PersistenceCaching/ConfigurationContainer.cs b/Examples/Caching/Examples.Caching.PersistenceCaching/ConfigurationContainer.cs
new file mode 100644
index 00000000..91637aa5
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.PersistenceCaching/ConfigurationContainer.cs
@@ -0,0 +1,14 @@
+using Microsoft.Extensions.Configuration;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Examples.Caching.PersistenceCaching
+{
+ internal static class ConfigurationContainer
+ {
+ public static IConfiguration Configuration { get; set; }
+ }
+}
diff --git a/Examples/Caching/Examples.Caching.PersistenceCaching/Examples.Caching.PersistenceCaching.csproj b/Examples/Caching/Examples.Caching.PersistenceCaching/Examples.Caching.PersistenceCaching.csproj
new file mode 100644
index 00000000..178eff2c
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.PersistenceCaching/Examples.Caching.PersistenceCaching.csproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Examples/Caching/Examples.Caching.PersistenceCaching/Program.cs b/Examples/Caching/Examples.Caching.PersistenceCaching/Program.cs
new file mode 100644
index 00000000..912fe152
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.PersistenceCaching/Program.cs
@@ -0,0 +1,67 @@
+using Examples.ApplicationServices.CQRS.Validators;
+using Examples.Caching.PersistenceCaching;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using RCommon;
+using RCommon.ApplicationServices;
+using RCommon.ApplicationServices.ExecutionResults;
+using RCommon.FluentValidation;
+using System.Diagnostics;
+using System.Reflection;
+
+try
+{
+ var host = Host.CreateDefaultBuilder(args)
+ .ConfigureAppConfiguration((context, builder) =>
+ {
+
+ ConfigurationContainer.Configuration = builder
+ .Build();
+ })
+ .ConfigureServices(services =>
+ {
+ // Configure RCommon
+ services.AddRCommon()
+ .WithCQRS(cqrs =>
+ {
+ // You can do it this way which is pretty straight forward but verbose
+ //cqrs.AddQueryHandler();
+ //cqrs.AddCommandHandler();
+
+ // Or this way which uses a little magic but is simple
+ cqrs.AddCommandHandlers((typeof(Program).GetTypeInfo().Assembly));
+ cqrs.AddQueryHandlers((typeof(Program).GetTypeInfo().Assembly));
+ })
+ .WithValidation(validation =>
+ {
+ validation.AddValidatorsFromAssemblyContaining(typeof(TestCommand));
+
+ validation.UseWithCqrs(options =>
+ {
+ options.ValidateCommands = true;
+ options.ValidateQueries = true;
+ });
+ });
+
+ services.AddTransient();
+
+ }).Build();
+
+ Console.WriteLine("Example Starting");
+ var appService = host.Services.GetRequiredService();
+ var commandResult = await appService.ExecuteTestCommand(new TestCommand("test"));
+ var queryResult = await appService.ExecuteTestQuery(new TestQuery());
+
+ Console.WriteLine(commandResult.ToString());
+ Console.WriteLine(queryResult.Message);
+
+ Console.WriteLine("Example Complete");
+ Console.ReadLine();
+}
+catch (Exception ex)
+{
+ Console.WriteLine(ex.ToString());
+
+}
+
diff --git a/Examples/Caching/Examples.Caching.PersistenceCaching/TestApplicationService.cs b/Examples/Caching/Examples.Caching.PersistenceCaching/TestApplicationService.cs
new file mode 100644
index 00000000..c9c91b3f
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.PersistenceCaching/TestApplicationService.cs
@@ -0,0 +1,33 @@
+using RCommon.ApplicationServices.Commands;
+using RCommon.ApplicationServices.ExecutionResults;
+using RCommon.ApplicationServices.Queries;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Examples.Caching.PersistenceCaching
+{
+ public class TestApplicationService : ITestApplicationService
+ {
+ private readonly ICommandBus _commandBus;
+ private readonly IQueryBus _queryBus;
+
+ public TestApplicationService(ICommandBus commandBus, IQueryBus queryBus)
+ {
+ _commandBus = commandBus;
+ _queryBus = queryBus;
+ }
+
+ public async Task ExecuteTestQuery(TestQuery query)
+ {
+ return await _queryBus.DispatchQueryAsync(query, CancellationToken.None);
+ }
+
+ public async Task ExecuteTestCommand(TestCommand command)
+ {
+ return await _commandBus.DispatchCommandAsync(command, CancellationToken.None);
+ }
+ }
+}
diff --git a/Examples/Caching/Examples.Caching.RedisCaching/ConfigurationContainer.cs b/Examples/Caching/Examples.Caching.RedisCaching/ConfigurationContainer.cs
new file mode 100644
index 00000000..be07627b
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.RedisCaching/ConfigurationContainer.cs
@@ -0,0 +1,14 @@
+using Microsoft.Extensions.Configuration;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Examples.Caching.RedisCaching
+{
+ internal static class ConfigurationContainer
+ {
+ public static IConfiguration Configuration { get; set; }
+ }
+}
diff --git a/Examples/Caching/Examples.Caching.RedisCaching/Examples.Caching.RedisCaching.csproj b/Examples/Caching/Examples.Caching.RedisCaching/Examples.Caching.RedisCaching.csproj
new file mode 100644
index 00000000..5ef0ed61
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.RedisCaching/Examples.Caching.RedisCaching.csproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Examples/Caching/Examples.Caching.RedisCaching/Program.cs b/Examples/Caching/Examples.Caching.RedisCaching/Program.cs
new file mode 100644
index 00000000..2ce9f68a
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.RedisCaching/Program.cs
@@ -0,0 +1,67 @@
+using Examples.ApplicationServices.CQRS.Validators;
+using Examples.Caching.RedisCaching;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using RCommon;
+using RCommon.ApplicationServices;
+using RCommon.ApplicationServices.ExecutionResults;
+using RCommon.FluentValidation;
+using System.Diagnostics;
+using System.Reflection;
+
+try
+{
+ var host = Host.CreateDefaultBuilder(args)
+ .ConfigureAppConfiguration((context, builder) =>
+ {
+
+ ConfigurationContainer.Configuration = builder
+ .Build();
+ })
+ .ConfigureServices(services =>
+ {
+ // Configure RCommon
+ services.AddRCommon()
+ .WithCQRS(cqrs =>
+ {
+ // You can do it this way which is pretty straight forward but verbose
+ //cqrs.AddQueryHandler();
+ //cqrs.AddCommandHandler();
+
+ // Or this way which uses a little magic but is simple
+ cqrs.AddCommandHandlers((typeof(Program).GetTypeInfo().Assembly));
+ cqrs.AddQueryHandlers((typeof(Program).GetTypeInfo().Assembly));
+ })
+ .WithValidation(validation =>
+ {
+ validation.AddValidatorsFromAssemblyContaining(typeof(TestCommand));
+
+ validation.UseWithCqrs(options =>
+ {
+ options.ValidateCommands = true;
+ options.ValidateQueries = true;
+ });
+ });
+
+ services.AddTransient();
+
+ }).Build();
+
+ Console.WriteLine("Example Starting");
+ var appService = host.Services.GetRequiredService();
+ var commandResult = await appService.ExecuteTestCommand(new TestCommand("test"));
+ var queryResult = await appService.ExecuteTestQuery(new TestQuery());
+
+ Console.WriteLine(commandResult.ToString());
+ Console.WriteLine(queryResult.Message);
+
+ Console.WriteLine("Example Complete");
+ Console.ReadLine();
+}
+catch (Exception ex)
+{
+ Console.WriteLine(ex.ToString());
+
+}
+
diff --git a/Examples/Caching/Examples.Caching.RedisCaching/TestApplicationService.cs b/Examples/Caching/Examples.Caching.RedisCaching/TestApplicationService.cs
new file mode 100644
index 00000000..af7a92cd
--- /dev/null
+++ b/Examples/Caching/Examples.Caching.RedisCaching/TestApplicationService.cs
@@ -0,0 +1,33 @@
+using RCommon.ApplicationServices.Commands;
+using RCommon.ApplicationServices.ExecutionResults;
+using RCommon.ApplicationServices.Queries;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Examples.Caching.RedisCaching
+{
+ public class TestApplicationService : ITestApplicationService
+ {
+ private readonly ICommandBus _commandBus;
+ private readonly IQueryBus _queryBus;
+
+ public TestApplicationService(ICommandBus commandBus, IQueryBus queryBus)
+ {
+ _commandBus = commandBus;
+ _queryBus = queryBus;
+ }
+
+ public async Task ExecuteTestQuery(TestQuery query)
+ {
+ return await _queryBus.DispatchQueryAsync(query, CancellationToken.None);
+ }
+
+ public async Task ExecuteTestCommand(TestCommand command)
+ {
+ return await _commandBus.DispatchCommandAsync(command, CancellationToken.None);
+ }
+ }
+}
diff --git a/Examples/Examples.sln b/Examples/Examples.sln
index 85a846b8..d76f21e5 100644
--- a/Examples/Examples.sln
+++ b/Examples/Examples.sln
@@ -119,15 +119,31 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Validation.FluentV
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.Persistence.Caching", "..\Src\RCommon.Persistence.Caching\RCommon.Persistence.Caching.csproj", "{B66429EB-4B5F-42F9-9CD7-7334190A14F4}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RCommon.JsonNet", "..\Src\RCommon.JsonNet\RCommon.JsonNet.csproj", "{6E3ED0D2-0619-4CB6-BAE2-10488DF061C6}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.JsonNet", "..\Src\RCommon.JsonNet\RCommon.JsonNet.csproj", "{6E3ED0D2-0619-4CB6-BAE2-10488DF061C6}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RCommon.Json", "..\Src\RCommon.Json\RCommon.Json.csproj", "{36386A61-2408-44D7-8C4A-4748F79623FC}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.Json", "..\Src\RCommon.Json\RCommon.Json.csproj", "{36386A61-2408-44D7-8C4A-4748F79623FC}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RCommon.Caching", "..\Src\RCommon.Caching\RCommon.Caching.csproj", "{6C91AB35-2238-4EF5-82BF-81B3C3EF7061}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.Caching", "..\Src\RCommon.Caching\RCommon.Caching.csproj", "{6C91AB35-2238-4EF5-82BF-81B3C3EF7061}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.RedisCache", "..\Src\RCommon.RedisCache\RCommon.RedisCache.csproj", "{10B9612F-DE04-4007-BDDE-B3DEBCEE59EB}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RCommon.MemoryCache", "RCommon.MemoryCache\RCommon.MemoryCache.csproj", "{69FF5D3E-CB99-41BE-8DE4-82E9C69C71EF}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Caching", "Caching", "{AE7572F9-5B50-4718-9552-3853C05E1A24}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Caching.MemoryCaching", "Caching\Examples.Caching.MemoryCaching\Examples.Caching.MemoryCaching.csproj", "{A8F70B2D-965E-41E5-A0CC-9F48C673CCFB}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Caching.RedisCaching", "Caching\Examples.Caching.RedisCaching\Examples.Caching.RedisCaching.csproj", "{DB2C927A-6C16-4163-A492-5072F11B67D4}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Caching.PersistenceCaching", "Caching\Examples.Caching.PersistenceCaching\Examples.Caching.PersistenceCaching.csproj", "{720E1999-9A71-49FD-B527-C07CF4510C9C}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Json", "Json", "{A53F8891-29D2-449D-B9BA-062D19EC7834}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Json.JsonNet", "Json\Examples.Json.JsonNet\Examples.Json.JsonNet.csproj", "{5D9C635C-DDC0-4A54-A36D-D0F535638E79}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.Json.SystemTextJson", "Json\Examples.Json.SystemTextJson\Examples.Json.SystemTextJson.csproj", "{8F5C5AD3-8310-47A7-BB30-42C054D032E2}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.SystemTextJson", "..\Src\RCommon.SystemTextJson\RCommon.SystemTextJson.csproj", "{6C07FC1A-4339-42AA-AF5F-83570F81A5A4}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RCommon.MemoryCache", "..\Src\RCommon.MemoryCache\RCommon.MemoryCache.csproj", "{F5277287-1776-494B-92EE-7237D1B8949B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -331,10 +347,34 @@ Global
{10B9612F-DE04-4007-BDDE-B3DEBCEE59EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10B9612F-DE04-4007-BDDE-B3DEBCEE59EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10B9612F-DE04-4007-BDDE-B3DEBCEE59EB}.Release|Any CPU.Build.0 = Release|Any CPU
- {69FF5D3E-CB99-41BE-8DE4-82E9C69C71EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {69FF5D3E-CB99-41BE-8DE4-82E9C69C71EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {69FF5D3E-CB99-41BE-8DE4-82E9C69C71EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {69FF5D3E-CB99-41BE-8DE4-82E9C69C71EF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A8F70B2D-965E-41E5-A0CC-9F48C673CCFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A8F70B2D-965E-41E5-A0CC-9F48C673CCFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A8F70B2D-965E-41E5-A0CC-9F48C673CCFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A8F70B2D-965E-41E5-A0CC-9F48C673CCFB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DB2C927A-6C16-4163-A492-5072F11B67D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DB2C927A-6C16-4163-A492-5072F11B67D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DB2C927A-6C16-4163-A492-5072F11B67D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DB2C927A-6C16-4163-A492-5072F11B67D4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {720E1999-9A71-49FD-B527-C07CF4510C9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {720E1999-9A71-49FD-B527-C07CF4510C9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {720E1999-9A71-49FD-B527-C07CF4510C9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {720E1999-9A71-49FD-B527-C07CF4510C9C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5D9C635C-DDC0-4A54-A36D-D0F535638E79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5D9C635C-DDC0-4A54-A36D-D0F535638E79}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5D9C635C-DDC0-4A54-A36D-D0F535638E79}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5D9C635C-DDC0-4A54-A36D-D0F535638E79}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8F5C5AD3-8310-47A7-BB30-42C054D032E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8F5C5AD3-8310-47A7-BB30-42C054D032E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8F5C5AD3-8310-47A7-BB30-42C054D032E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8F5C5AD3-8310-47A7-BB30-42C054D032E2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6C07FC1A-4339-42AA-AF5F-83570F81A5A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6C07FC1A-4339-42AA-AF5F-83570F81A5A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6C07FC1A-4339-42AA-AF5F-83570F81A5A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6C07FC1A-4339-42AA-AF5F-83570F81A5A4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F5277287-1776-494B-92EE-7237D1B8949B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F5277287-1776-494B-92EE-7237D1B8949B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F5277287-1776-494B-92EE-7237D1B8949B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F5277287-1776-494B-92EE-7237D1B8949B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -386,7 +426,15 @@ Global
{256821F9-8160-4819-B0A1-B769C5BBBBB6} = {0F54DCE2-27A5-4D07-B542-6D2A7B50D0EC}
{6E3ED0D2-0619-4CB6-BAE2-10488DF061C6} = {3199F749-0082-41D0-91D3-ECED117F8B08}
{10B9612F-DE04-4007-BDDE-B3DEBCEE59EB} = {3199F749-0082-41D0-91D3-ECED117F8B08}
- {69FF5D3E-CB99-41BE-8DE4-82E9C69C71EF} = {3199F749-0082-41D0-91D3-ECED117F8B08}
+ {AE7572F9-5B50-4718-9552-3853C05E1A24} = {3234C3BB-1632-4684-838E-9D6D382D4D4D}
+ {A8F70B2D-965E-41E5-A0CC-9F48C673CCFB} = {AE7572F9-5B50-4718-9552-3853C05E1A24}
+ {DB2C927A-6C16-4163-A492-5072F11B67D4} = {AE7572F9-5B50-4718-9552-3853C05E1A24}
+ {720E1999-9A71-49FD-B527-C07CF4510C9C} = {AE7572F9-5B50-4718-9552-3853C05E1A24}
+ {A53F8891-29D2-449D-B9BA-062D19EC7834} = {3234C3BB-1632-4684-838E-9D6D382D4D4D}
+ {5D9C635C-DDC0-4A54-A36D-D0F535638E79} = {A53F8891-29D2-449D-B9BA-062D19EC7834}
+ {8F5C5AD3-8310-47A7-BB30-42C054D032E2} = {A53F8891-29D2-449D-B9BA-062D19EC7834}
+ {6C07FC1A-4339-42AA-AF5F-83570F81A5A4} = {3199F749-0082-41D0-91D3-ECED117F8B08}
+ {F5277287-1776-494B-92EE-7237D1B8949B} = {3199F749-0082-41D0-91D3-ECED117F8B08}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0B0CD26D-8067-4667-863E-6B0EE7EDAA42}
diff --git a/Examples/Json/Examples.Json.JsonNet/Examples.Json.JsonNet.csproj b/Examples/Json/Examples.Json.JsonNet/Examples.Json.JsonNet.csproj
new file mode 100644
index 00000000..643e0e9d
--- /dev/null
+++ b/Examples/Json/Examples.Json.JsonNet/Examples.Json.JsonNet.csproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Examples/Json/Examples.Json.JsonNet/Program.cs b/Examples/Json/Examples.Json.JsonNet/Program.cs
new file mode 100644
index 00000000..3751555c
--- /dev/null
+++ b/Examples/Json/Examples.Json.JsonNet/Program.cs
@@ -0,0 +1,2 @@
+// See https://aka.ms/new-console-template for more information
+Console.WriteLine("Hello, World!");
diff --git a/Examples/Json/Examples.Json.SystemTextJson/Examples.Json.SystemTextJson.csproj b/Examples/Json/Examples.Json.SystemTextJson/Examples.Json.SystemTextJson.csproj
new file mode 100644
index 00000000..2150e379
--- /dev/null
+++ b/Examples/Json/Examples.Json.SystemTextJson/Examples.Json.SystemTextJson.csproj
@@ -0,0 +1,10 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/Examples/Json/Examples.Json.SystemTextJson/Program.cs b/Examples/Json/Examples.Json.SystemTextJson/Program.cs
new file mode 100644
index 00000000..3751555c
--- /dev/null
+++ b/Examples/Json/Examples.Json.SystemTextJson/Program.cs
@@ -0,0 +1,2 @@
+// See https://aka.ms/new-console-template for more information
+Console.WriteLine("Hello, World!");
diff --git a/Src/RCommon.ApplicationServices/CqrsBuilder.cs b/Src/RCommon.ApplicationServices/CqrsBuilder.cs
index da489daa..1e165401 100644
--- a/Src/RCommon.ApplicationServices/CqrsBuilder.cs
+++ b/Src/RCommon.ApplicationServices/CqrsBuilder.cs
@@ -24,6 +24,7 @@ protected void RegisterServices(IServiceCollection services)
services.AddTransient();
services.AddTransient();
services.AddTransient(); // TODO: Allow CQRS configuration to choose caching strategy
+
}
public IServiceCollection Services { get; }
diff --git a/Src/RCommon.Caching/CachingBuilderExtensions.cs b/Src/RCommon.Caching/CachingBuilderExtensions.cs
new file mode 100644
index 00000000..0278d1c4
--- /dev/null
+++ b/Src/RCommon.Caching/CachingBuilderExtensions.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RCommon.Caching
+{
+ public static class CachingBuilderExtensions
+ {
+ public static IRCommonBuilder WithCaching(this IRCommonBuilder builder)
+ where T : ICachingBuilder
+ {
+ return WithCaching(builder, x => { });
+ }
+
+ public static IRCommonBuilder WithCaching(this IRCommonBuilder builder, Action actions)
+ where T : ICachingBuilder
+ {
+ Guard.IsNotNull(actions, nameof(actions));
+
+ // Event Handling Configurations
+ var cachingConfig = (T)Activator.CreateInstance(typeof(T), new object[] { builder });
+ actions(cachingConfig);
+ return builder;
+ }
+ }
+}
diff --git a/Src/RCommon.Caching/ICachingBuilder.cs b/Src/RCommon.Caching/ICachingBuilder.cs
new file mode 100644
index 00000000..fd0a0a2a
--- /dev/null
+++ b/Src/RCommon.Caching/ICachingBuilder.cs
@@ -0,0 +1,14 @@
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RCommon.Caching
+{
+ public interface ICachingBuilder
+ {
+ IServiceCollection Services { get; }
+ }
+}
diff --git a/Src/RCommon.Caching/RCommon.Caching.csproj b/Src/RCommon.Caching/RCommon.Caching.csproj
index cc6a561b..d7a528dd 100644
--- a/Src/RCommon.Caching/RCommon.Caching.csproj
+++ b/Src/RCommon.Caching/RCommon.Caching.csproj
@@ -10,4 +10,8 @@
+
+
+
+
diff --git a/Src/RCommon.Json/IJsonBuilder.cs b/Src/RCommon.Json/IJsonBuilder.cs
new file mode 100644
index 00000000..ff4ee589
--- /dev/null
+++ b/Src/RCommon.Json/IJsonBuilder.cs
@@ -0,0 +1,14 @@
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RCommon.Json
+{
+ public interface IJsonBuilder
+ {
+ IServiceCollection Services { get; }
+ }
+}
diff --git a/Src/RCommon.Json/JsonBuilderExtensions.cs b/Src/RCommon.Json/JsonBuilderExtensions.cs
new file mode 100644
index 00000000..f6a977ad
--- /dev/null
+++ b/Src/RCommon.Json/JsonBuilderExtensions.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RCommon.Json
+{
+ public static class JsonBuilderExtensions
+ {
+ }
+}
diff --git a/Src/RCommon.Json/JsonSerializeOptions.cs b/Src/RCommon.Json/JsonSerializeOptions.cs
index dcc3e431..2996532c 100644
--- a/Src/RCommon.Json/JsonSerializeOptions.cs
+++ b/Src/RCommon.Json/JsonSerializeOptions.cs
@@ -8,5 +8,13 @@ namespace RCommon.Json
{
public class JsonSerializeOptions
{
+ public JsonSerializeOptions()
+ {
+ this.CamelCase = true;
+ this.Indented = false;
+ }
+
+ public bool CamelCase { get; set; }
+ public bool Indented { get; set; }
}
}
diff --git a/Src/RCommon.Json/RCommon.Json.csproj b/Src/RCommon.Json/RCommon.Json.csproj
index fa71b7ae..e79b9d93 100644
--- a/Src/RCommon.Json/RCommon.Json.csproj
+++ b/Src/RCommon.Json/RCommon.Json.csproj
@@ -6,4 +6,12 @@
enable
+
+
+
+
+
+
+
+
diff --git a/Src/RCommon.JsonNet/JsonNetSerializer.cs b/Src/RCommon.JsonNet/JsonNetSerializer.cs
index d194ee9a..58fa7caa 100644
--- a/Src/RCommon.JsonNet/JsonNetSerializer.cs
+++ b/Src/RCommon.JsonNet/JsonNetSerializer.cs
@@ -1,6 +1,9 @@
-using System;
+using Microsoft.Extensions.Options;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.InteropServices.Marshalling;
using System.Text;
using System.Threading.Tasks;
@@ -8,9 +11,16 @@ namespace RCommon.JsonNet
{
public class JsonNetSerializer
{
- public JsonNetSerializer()
+ private readonly JsonSerializerSettings _settings;
+
+ public JsonNetSerializer(IOptions options)
+ {
+ _settings = options.Value;
+ }
+
+ public string Serialize(object obj, Jsonser)
{
-
+ return JsonConvert.SerializeObject(obj, _settings); ;
}
}
}
diff --git a/Src/RCommon.JsonNet/RCommon.JsonNet.csproj b/Src/RCommon.JsonNet/RCommon.JsonNet.csproj
index 3b5b1707..2e2a30c1 100644
--- a/Src/RCommon.JsonNet/RCommon.JsonNet.csproj
+++ b/Src/RCommon.JsonNet/RCommon.JsonNet.csproj
@@ -7,6 +7,7 @@
+
diff --git a/Src/RCommon.Mediatr/Behaviors/UnitOfWorkBehavior.cs b/Src/RCommon.Mediatr/Behaviors/UnitOfWorkBehavior.cs
index 2f8b8ef9..f025e026 100644
--- a/Src/RCommon.Mediatr/Behaviors/UnitOfWorkBehavior.cs
+++ b/Src/RCommon.Mediatr/Behaviors/UnitOfWorkBehavior.cs
@@ -41,7 +41,6 @@ public async Task Handle(TRequest request, RequestHandlerDelegate Handle(TRequest request, RequestHandlerDelegate();
}
diff --git a/Src/RCommon.MemoryCache/IMemoryCachingBuilder.cs b/Src/RCommon.MemoryCache/IMemoryCachingBuilder.cs
new file mode 100644
index 00000000..d02361b4
--- /dev/null
+++ b/Src/RCommon.MemoryCache/IMemoryCachingBuilder.cs
@@ -0,0 +1,13 @@
+using RCommon.Caching;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RCommon.MemoryCache
+{
+ public interface IMemoryCachingBuilder : ICachingBuilder
+ {
+ }
+}
diff --git a/Src/RCommon.MemoryCache/IMemoryCachingBuilderExtensions.cs b/Src/RCommon.MemoryCache/IMemoryCachingBuilderExtensions.cs
new file mode 100644
index 00000000..35f88626
--- /dev/null
+++ b/Src/RCommon.MemoryCache/IMemoryCachingBuilderExtensions.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RCommon.MemoryCache
+{
+ public static class IMemoryCachingBuilderExtensions
+ {
+ }
+}
diff --git a/Src/RCommon.RedisCache/IRedisCachingBuilder.cs b/Src/RCommon.RedisCache/IRedisCachingBuilder.cs
new file mode 100644
index 00000000..55fafbcd
--- /dev/null
+++ b/Src/RCommon.RedisCache/IRedisCachingBuilder.cs
@@ -0,0 +1,13 @@
+using RCommon.Caching;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RCommon.RedisCache
+{
+ public interface IRedisCachingBuilder : ICachingBuilder
+ {
+ }
+}
diff --git a/Src/RCommon.RedisCache/IRedisCachingBuilderExtensions.cs b/Src/RCommon.RedisCache/IRedisCachingBuilderExtensions.cs
new file mode 100644
index 00000000..a2b93dc2
--- /dev/null
+++ b/Src/RCommon.RedisCache/IRedisCachingBuilderExtensions.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RCommon.RedisCache
+{
+ public static class IRedisCachingBuilderExtensions
+ {
+ }
+}
diff --git a/Src/RCommon.RedisCache/RedisCachingBuilder.cs b/Src/RCommon.RedisCache/RedisCachingBuilder.cs
new file mode 100644
index 00000000..39a31100
--- /dev/null
+++ b/Src/RCommon.RedisCache/RedisCachingBuilder.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RCommon.RedisCache
+{
+ public static class RedisCachingBuilder
+ {
+ }
+}
diff --git a/Src/RCommon.SystemTextJson/ITextJsonBuilder.cs b/Src/RCommon.SystemTextJson/ITextJsonBuilder.cs
new file mode 100644
index 00000000..539c7b15
--- /dev/null
+++ b/Src/RCommon.SystemTextJson/ITextJsonBuilder.cs
@@ -0,0 +1,13 @@
+using RCommon.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RCommon.SystemTextJson
+{
+ public interface ITextJsonBuilder : IJsonBuilder
+ {
+ }
+}
diff --git a/Src/RCommon.SystemTextJson/ITextJsonBuilderExtensions.cs b/Src/RCommon.SystemTextJson/ITextJsonBuilderExtensions.cs
new file mode 100644
index 00000000..fc11584d
--- /dev/null
+++ b/Src/RCommon.SystemTextJson/ITextJsonBuilderExtensions.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RCommon.SystemTextJson
+{
+ public static class ITextJsonBuilderExtensions
+ {
+ }
+}
diff --git a/Src/RCommon.SystemTextJson/RCommon.SystemTextJson.csproj b/Src/RCommon.SystemTextJson/RCommon.SystemTextJson.csproj
new file mode 100644
index 00000000..d7f99a04
--- /dev/null
+++ b/Src/RCommon.SystemTextJson/RCommon.SystemTextJson.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Src/RCommon.SystemTextJson/TextJsonSerializer.cs b/Src/RCommon.SystemTextJson/TextJsonSerializer.cs
new file mode 100644
index 00000000..c5897f46
--- /dev/null
+++ b/Src/RCommon.SystemTextJson/TextJsonSerializer.cs
@@ -0,0 +1,32 @@
+using Microsoft.Extensions.Options;
+using RCommon.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+
+namespace RCommon.SystemTextJson
+{
+ public class TextJsonSerializer
+ {
+ private JsonSerializerOptions _jsonOptions;
+
+ public TextJsonSerializer(IOptions options)
+ {
+ _jsonOptions = options.Value;
+ }
+
+ public string Serialize(object obj, JsonSerializeOptions options)
+ {
+ _jsonOptions.WriteIndented = options.Indented;
+
+ if (options.CamelCase)
+ {
+ _jsonOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
+ }
+ return JsonSerializer.Serialize(obj, _jsonOptions);
+ }
+ }
+}