Skip to content

Commit

Permalink
#371 Introduce caching abstractions and mediator extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjstone committed Nov 27, 2020
1 parent 59889b5 commit 06c1fcc
Show file tree
Hide file tree
Showing 83 changed files with 4,615 additions and 25 deletions.
3 changes: 3 additions & 0 deletions RapidField.SolidInstruments.sln
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "namespaces", "namespaces",
doc\namespaces\RapidField.SolidInstruments.Command.Autofac.md = doc\namespaces\RapidField.SolidInstruments.Command.Autofac.md
doc\namespaces\RapidField.SolidInstruments.Command.DotNetNative.Extensions.md = doc\namespaces\RapidField.SolidInstruments.Command.DotNetNative.Extensions.md
doc\namespaces\RapidField.SolidInstruments.Command.DotNetNative.md = doc\namespaces\RapidField.SolidInstruments.Command.DotNetNative.md
doc\namespaces\RapidField.SolidInstruments.Command.Extensions.md = doc\namespaces\RapidField.SolidInstruments.Command.Extensions.md
doc\namespaces\RapidField.SolidInstruments.Command.md = doc\namespaces\RapidField.SolidInstruments.Command.md
doc\namespaces\RapidField.SolidInstruments.Core.ArgumentValidation.md = doc\namespaces\RapidField.SolidInstruments.Core.ArgumentValidation.md
doc\namespaces\RapidField.SolidInstruments.Core.Caching.md = doc\namespaces\RapidField.SolidInstruments.Core.Caching.md
doc\namespaces\RapidField.SolidInstruments.Core.Concurrency.md = doc\namespaces\RapidField.SolidInstruments.Core.Concurrency.md
doc\namespaces\RapidField.SolidInstruments.Core.Domain.md = doc\namespaces\RapidField.SolidInstruments.Core.Domain.md
doc\namespaces\RapidField.SolidInstruments.Core.Extensions.md = doc\namespaces\RapidField.SolidInstruments.Core.Extensions.md
Expand Down Expand Up @@ -250,6 +252,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "namespaces", "namespaces",
doc\namespaces\RapidField.SolidInstruments.Messaging.DotNetNative.Rmq.Extensions.md = doc\namespaces\RapidField.SolidInstruments.Messaging.DotNetNative.Rmq.Extensions.md
doc\namespaces\RapidField.SolidInstruments.Messaging.DotNetNative.Rmq.md = doc\namespaces\RapidField.SolidInstruments.Messaging.DotNetNative.Rmq.md
doc\namespaces\RapidField.SolidInstruments.Messaging.EventMessages.md = doc\namespaces\RapidField.SolidInstruments.Messaging.EventMessages.md
doc\namespaces\RapidField.SolidInstruments.Messaging.Extensions.md = doc\namespaces\RapidField.SolidInstruments.Messaging.Extensions.md
doc\namespaces\RapidField.SolidInstruments.Messaging.InMemory.md = doc\namespaces\RapidField.SolidInstruments.Messaging.InMemory.md
doc\namespaces\RapidField.SolidInstruments.Messaging.md = doc\namespaces\RapidField.SolidInstruments.Messaging.md
doc\namespaces\RapidField.SolidInstruments.Messaging.RabbitMq.md = doc\namespaces\RapidField.SolidInstruments.Messaging.RabbitMq.md
Expand Down
31 changes: 31 additions & 0 deletions doc/namespaces/RapidField.SolidInstruments.Command.Extensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
uid: RapidField.SolidInstruments.Command.Extensions
summary: *content
---

<!--
Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
-->

Exposes extensions that support the command and mediator patterns.

<br />

![Command label](../images/Label.Command.300w.png)
- - -

### Installation

This library is available via [**NuGet**](https://docs.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio). Use one of the commands below to download and install the library and all of its dependencies.

###### .NET CLI

```shell
dotnet add package RapidField.SolidInstruments.Command
```

###### NuGet Package Manager

```shell
Install-Package RapidField.SolidInstruments.Command
```
6 changes: 6 additions & 0 deletions doc/namespaces/RapidField.SolidInstruments.Command.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,10 @@ Exposes the Autofac integration for the Solid Instruments implementations of the

<section>
Exposes the native .NET IoC integration for the Solid Instruments implementations of the command and mediator patterns.
</section>

#### [RapidField.SolidInstruments.Command.Extensions](https://www.solidinstruments.com/api/RapidField.SolidInstruments.Command.Extensions.html)

<section>
Exposes extensions that support the command and mediator patterns.
</section>
31 changes: 31 additions & 0 deletions doc/namespaces/RapidField.SolidInstruments.Core.Caching.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
uid: RapidField.SolidInstruments.Core.Caching
summary: *content
---

<!--
Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
-->

Exposes configurable clients for accessing cached data.

<br />

![Core label](../images/Label.Core.300w.png)
- - -

### Installation

This library is available via [**NuGet**](https://docs.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio). Use one of the commands below to download and install the library and all of its dependencies.

###### .NET CLI

```shell
dotnet add package RapidField.SolidInstruments.Core
```

###### NuGet Package Manager

```shell
Install-Package RapidField.SolidInstruments.Core
```
6 changes: 6 additions & 0 deletions doc/namespaces/RapidField.SolidInstruments.Core.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ Install-Package RapidField.SolidInstruments.Core
Defines a fluent pattern for evaluating argument validity.
</section>

#### [RapidField.SolidInstruments.Core.Caching](https://www.solidinstruments.com/api/RapidField.SolidInstruments.Core.Caching.html)

<section>
Exposes configurable clients for accessing cached data.
</section>

#### [RapidField.SolidInstruments.Core.Concurrency](https://www.solidinstruments.com/api/RapidField.SolidInstruments.Core.Concurrency.html)

<section>
Expand Down
31 changes: 31 additions & 0 deletions doc/namespaces/RapidField.SolidInstruments.Messaging.Extensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
uid: RapidField.SolidInstruments.Messaging.Extensions
summary: *content
---

<!--
Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
-->

Exposes extensions that support messaging abstractions.

<br />

![Messaging label](../images/Label.Messaging.300w.png)
- - -

### Installation

This library is available via [**NuGet**](https://docs.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio). Use one of the commands below to download and install the library and all of its dependencies.

###### .NET CLI

```shell
dotnet add package RapidField.SolidInstruments.Messaging
```

###### NuGet Package Manager

```shell
Install-Package RapidField.SolidInstruments.Messaging
```
6 changes: 6 additions & 0 deletions doc/namespaces/RapidField.SolidInstruments.Messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ Exposes the native .NET IoC integration for the Solid Instruments messaging abst
Exposes various event message types.
</section>

#### [RapidField.SolidInstruments.Messaging.Extensions](https://www.solidinstruments.com/api/RapidField.SolidInstruments.Messaging.Extensions.html)

<section>
Exposes extensions that support messaging abstractions.
</section>

#### [RapidField.SolidInstruments.Messaging.Service](https://www.solidinstruments.com/api/RapidField.SolidInstruments.Messaging.Service.html)

<section>
Expand Down
1 change: 1 addition & 0 deletions en-US_User.dic
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ composable
configurator
configurators
contentfiles
creational
cryptographic
cryptographically
csharp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using RapidField.SolidInstruments.Core;
using RapidField.SolidInstruments.InversionOfControl;
using RapidField.SolidInstruments.Messaging.DotNetNative.Service;
using RapidField.SolidInstruments.Messaging.Extensions;
using RapidField.SolidInstruments.Messaging.Service;
using RapidField.SolidInstruments.Service;
using System;
Expand Down Expand Up @@ -269,7 +270,7 @@ private static void TestServiceBusConnectivity(IDependencyScope dependencyScope)
{
var mediator = dependencyScope.Resolve<ICommandMediator>();
var pingRequestCorrelationIdentifier = Guid.NewGuid();
var pingResponseMessage = mediator.Process<PingResponseMessage>(new PingRequestMessage(pingRequestCorrelationIdentifier));
var pingResponseMessage = mediator.TransmitRequestMessage(register => register.Ping(pingRequestCorrelationIdentifier));

if (pingResponseMessage is null || pingResponseMessage.CorrelationIdentifier != pingRequestCorrelationIdentifier)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using RapidField.SolidInstruments.Core;
using RapidField.SolidInstruments.InversionOfControl;
using RapidField.SolidInstruments.Messaging.DotNetNative.Service;
using RapidField.SolidInstruments.Messaging.Extensions;
using RapidField.SolidInstruments.Messaging.Service;
using RapidField.SolidInstruments.Service;
using System;
Expand Down Expand Up @@ -196,7 +197,7 @@ private static void TestServiceBusConnectivity(IDependencyScope dependencyScope)
{
var mediator = dependencyScope.Resolve<ICommandMediator>();
var pingRequestCorrelationIdentifier = Guid.NewGuid();
var pingResponseMessage = mediator.Process<PingResponseMessage>(new PingRequestMessage(pingRequestCorrelationIdentifier));
var pingResponseMessage = mediator.TransmitRequestMessage(register => register.Ping(pingRequestCorrelationIdentifier));

if (pingResponseMessage is null || pingResponseMessage.CorrelationIdentifier != pingRequestCorrelationIdentifier)
{
Expand Down
4 changes: 2 additions & 2 deletions src/RapidField.SolidInstruments.Collections/BinaryTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public BinaryTreeNode(T value, BinaryTreeNode<T> leftChild, BinaryTreeNode<T> ri
private BinaryTreeNode(T value, BinaryTreeNode<T> leftChild, BinaryTreeNode<T> rightChild, Boolean rejectNullLeftChild, Boolean rejectNullRightChild)
: base(value, 2)
{
if ((leftChild is null) == false)
if (leftChild is not null)
{
if (AddChild(leftChild) == false)
{
Expand All @@ -130,7 +130,7 @@ private BinaryTreeNode(T value, BinaryTreeNode<T> leftChild, BinaryTreeNode<T> r
leftChild.RejectIf().IsNull(nameof(leftChild));
}

if ((rightChild is null) == false)
if (rightChild is not null)
{
if (AddChild(rightChild) == false)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using RapidField.SolidInstruments.Command.Autofac.Extensions;
using RapidField.SolidInstruments.Core.ArgumentValidation;
using RapidField.SolidInstruments.InversionOfControl.Autofac;
using RapidField.SolidInstruments.InversionOfControl.Autofac.Extensions;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -111,6 +112,9 @@ protected AutofacCommandHandlerModule(IConfiguration applicationConfiguration, A
/// </param>
protected sealed override void Configure(ContainerBuilder configurator, IConfiguration applicationConfiguration)
{
configurator.RegisterApplicationConfiguration(applicationConfiguration);
configurator.RegisterConfigurationCommandHandlers();

foreach (var commandHandlerType in MatchedTypes)
{
var commandHandlerInterfaceType = commandHandlerType.GetInterfaces().Where(implementedInterface => CommandHandlerInterfaceType.IsAssignableFrom(implementedInterface) && implementedInterface.GenericTypeArguments.Length == 1).FirstOrDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// =================================================================================================================================

using Autofac;
using RapidField.SolidInstruments.Command.Configuration;
using RapidField.SolidInstruments.Core;
using RapidField.SolidInstruments.Core.ArgumentValidation;
using System;
Expand Down Expand Up @@ -58,6 +59,19 @@ public static void RegisterCommandHandler(this ContainerBuilder target, Type com
target.RegisterType(commandHandlerType.RejectIf().IsNull(nameof(commandHandlerType)).OrIf().IsNotSupportedType(commandHandlerInterfaceType, nameof(commandHandlerType))).IfNotRegistered(commandHandlerType).As(commandHandlerInterfaceType).InstancePerDependency();
}

/// <summary>
/// Registers transient command handlers for retrieving configuration sections and values.
/// </summary>
/// <param name="target">
/// The current <see cref="ContainerBuilder" />.
/// </param>
public static void RegisterConfigurationCommandHandlers(this ContainerBuilder target)
{
target.RegisterCommandHandler<GetConfigurationSectionCommand, GetConfigurationSectionCommandHandler>();
target.RegisterCommandHandler<GetConfigurationValueCommand, GetConfigurationValueCommandHandler>();
target.RegisterCommandHandler<GetConnectionStringCommand, GetConnectionStringCommandHandler>();
}

/// <summary>
/// Represents the <see cref="ICommandBase" /> type.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using RapidField.SolidInstruments.Command.DotNetNative.Extensions;
using RapidField.SolidInstruments.Core.ArgumentValidation;
using RapidField.SolidInstruments.InversionOfControl.DotNetNative;
using RapidField.SolidInstruments.InversionOfControl.DotNetNative.Extensions;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -111,6 +112,9 @@ protected DotNetNativeCommandHandlerModule(IConfiguration applicationConfigurati
/// </param>
protected sealed override void Configure(ServiceCollection configurator, IConfiguration applicationConfiguration)
{
configurator.AddApplicationConfiguration(applicationConfiguration);
configurator.AddConfigurationCommandHandlers();

foreach (var commandHandlerType in MatchedTypes)
{
var commandHandlerInterfaceType = commandHandlerType.GetInterfaces().Where(implementedInterface => CommandHandlerInterfaceType.IsAssignableFrom(implementedInterface) && implementedInterface.GenericTypeArguments.Length == 1).FirstOrDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using RapidField.SolidInstruments.Command.Configuration;
using RapidField.SolidInstruments.Core;
using RapidField.SolidInstruments.Core.ArgumentValidation;
using System;
Expand Down Expand Up @@ -66,6 +67,23 @@ public static IServiceCollection AddCommandHandler(this IServiceCollection targe
return target;
}

/// <summary>
/// Registers transient command handlers for retrieving configuration sections and values.
/// </summary>
/// <param name="target">
/// The current <see cref="IServiceCollection" />.
/// </param>
/// <returns>
/// The resulting <see cref="IServiceCollection" />.
/// </returns>
public static IServiceCollection AddConfigurationCommandHandlers(this IServiceCollection target)
{
target.AddCommandHandler<GetConfigurationSectionCommand, GetConfigurationSectionCommandHandler>();
target.AddCommandHandler<GetConfigurationValueCommand, GetConfigurationValueCommandHandler>();
target.AddCommandHandler<GetConnectionStringCommand, GetConnectionStringCommandHandler>();
return target;
}

/// <summary>
/// Represents the <see cref="ICommandBase" /> type.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ public CommandHandlingException(String message)
return;
}

/// <summary>
/// Initializes a new instance of the <see cref="CommandHandlingException" />
/// </summary>
/// <param name="innerException">
/// The exception that is the cause of the current exception.
/// </param>
public CommandHandlingException(Exception innerException)
: this(commandType: null, innerException: innerException)
{
return;
}

/// <summary>
/// Initializes a new instance of the <see cref="CommandHandlingException" />
/// </summary>
Expand Down
32 changes: 32 additions & 0 deletions src/RapidField.SolidInstruments.Command/CommandRegister.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================

using System.Diagnostics;

namespace RapidField.SolidInstruments.Command
{
/// <summary>
/// Represents an extensible catalog of available commands.
/// </summary>
/// <remarks>
/// <see cref="CommandRegister" /> is the default implementation of <see cref="ICommandRegister" />.
/// </remarks>
public sealed class CommandRegister : ICommandRegister
{
/// <summary>
/// Initializes a new instance of the <see cref="CommandRegister" /> class.
/// </summary>
[DebuggerHidden]
private CommandRegister()
{
return;
}

/// <summary>
/// Represents a singleton instance of the <see cref="CommandRegister" /> class.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
internal static readonly ICommandRegister Instance = new CommandRegister();
}
}
Loading

0 comments on commit 06c1fcc

Please sign in to comment.