Skip to content

Commit

Permalink
#371 Introduce user role example models.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjstone committed Aug 26, 2020
1 parent 9b305c7 commit 1cca248
Show file tree
Hide file tree
Showing 82 changed files with 2,878 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ dotnet_diagnostic.CA1027.severity = silent
# CA1031: Do not catch general exception types
dotnet_diagnostic.CA1031.severity = silent

# CA1034: Nested types should not be visible
dotnet_diagnostic.CA1034.severity = silent

# IDE0075: Simplify conditional expression
dotnet_style_prefer_simplified_boolean_expressions = false : none

Expand Down
9 changes: 8 additions & 1 deletion RapidField.SolidInstruments.sln
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RapidField.SolidInstruments
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RapidField.SolidInstruments.Example.Domain.AccessControl", "example\RapidField.SolidInstruments.Example.Domain.AccessControl\RapidField.SolidInstruments.Example.Domain.AccessControl.csproj", "{7B185E3A-3A26-4188-9FB4-DED7E4EF5C3D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RapidField.SolidInstruments.Example.Domain.AccessControl.Service", "example\RapidField.SolidInstruments.Example.Domain.AccessControl.Service\RapidField.SolidInstruments.Example.Domain.AccessControl.Service.csproj", "{77026FD0-F0DC-48B8-A678-0E67BDCC29EB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RapidField.SolidInstruments.Example.Domain.AccessControl.Service", "example\RapidField.SolidInstruments.Example.Domain.AccessControl.Service\RapidField.SolidInstruments.Example.Domain.AccessControl.Service.csproj", "{77026FD0-F0DC-48B8-A678-0E67BDCC29EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RapidField.SolidInstruments.Example.BeaconService", "example\RapidField.SolidInstruments.Example.BeaconService\RapidField.SolidInstruments.Example.BeaconService.csproj", "{423CCBD1-0299-4C1A-BFDB-05AF2BF4847A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -625,6 +627,10 @@ Global
{77026FD0-F0DC-48B8-A678-0E67BDCC29EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77026FD0-F0DC-48B8-A678-0E67BDCC29EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77026FD0-F0DC-48B8-A678-0E67BDCC29EB}.Release|Any CPU.Build.0 = Release|Any CPU
{423CCBD1-0299-4C1A-BFDB-05AF2BF4847A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{423CCBD1-0299-4C1A-BFDB-05AF2BF4847A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{423CCBD1-0299-4C1A-BFDB-05AF2BF4847A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{423CCBD1-0299-4C1A-BFDB-05AF2BF4847A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -700,6 +706,7 @@ Global
{F20759D5-D39D-4C31-8A23-AEAA606776E6} = {F58E05BE-9DC6-41B4-8324-C006F6CE7CC7}
{7B185E3A-3A26-4188-9FB4-DED7E4EF5C3D} = {BEB60D41-11BB-4C6E-8F5D-1E7990A27C34}
{77026FD0-F0DC-48B8-A678-0E67BDCC29EB} = {BEB60D41-11BB-4C6E-8F5D-1E7990A27C34}
{423CCBD1-0299-4C1A-BFDB-05AF2BF4847A} = {BEB60D41-11BB-4C6E-8F5D-1E7990A27C34}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {834FCFB0-DA00-4ABD-9424-6FE1398A9F6E}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Install-Package RapidField.SolidInstruments.Messaging.Autofac.Rmq

### Namespaces

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

<section>
Exposes extensions that support the Autofac IoC integration for the Solid Instruments RabbitMQ messaging abstractions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Install-Package RapidField.SolidInstruments.Messaging.DotNetNative.Rmq

### Namespaces

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

<section>
Exposes extensions that support the DotNetNative IoC integration for the Solid Instruments RabbitMQ messaging abstractions.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using RapidField.SolidInstruments.Example.Domain;
using RapidField.SolidInstruments.InversionOfControl;
using RapidField.SolidInstruments.InversionOfControl.DotNetNative;
using System.Collections.Generic;

namespace RapidField.SolidInstruments.Example.BeaconService
{
/// <summary>
/// Encapsulates container configuration for the application.
/// </summary>
public class ApplicationDependencyPackage : DotNetNativeDependencyPackage
{
/// <summary>
/// Initializes a new instance of the <see cref="ApplicationDependencyPackage" /> class.
/// </summary>
public ApplicationDependencyPackage()
: base()
{
return;
}

/// <summary>
/// Creates a new collection of dependency modules for the package.
/// </summary>
/// <param name="applicationConfiguration">
/// Configuration information for the application.
/// </param>
/// <returns>
/// The package's dependency modules.
/// </returns>
protected override IEnumerable<IDependencyModule<ServiceCollection>> CreateModules(IConfiguration applicationConfiguration) => new IDependencyModule<ServiceCollection>[]
{
new ServiceBusDependencyModule(applicationConfiguration),
new MessageHandlerModule(applicationConfiguration)
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================

using Microsoft.Extensions.Configuration;
using RapidField.SolidInstruments.Messaging.DotNetNative.Service;
using System;
using System.IO;

namespace RapidField.SolidInstruments.Example.BeaconService
{
/// <summary>
/// Prepares for and performs execution of the beacon service.
/// </summary>
public sealed class ApplicationServiceExecutor : DotNetNativeBeaconServiceExecutor<ApplicationDependencyPackage>
{
/// <summary>
/// Initializes a new instance of the <see cref="ApplicationServiceExecutor" /> class.
/// </summary>
public ApplicationServiceExecutor()
: base(true, false, false, false, false)
{
return;
}

/// <summary>
/// Builds the application configuration for the service.
/// </summary>
/// <param name="configurationBuilder">
/// An object that is used to build the configuration.
/// </param>
protected override void BuildConfiguration(IConfigurationBuilder configurationBuilder)
{
try
{
configurationBuilder.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
}
finally
{
base.BuildConfiguration(configurationBuilder);
}
}

/// <summary>
/// Releases all resources consumed by the current <see cref="ApplicationServiceExecutor" />.
/// </summary>
/// <param name="disposing">
/// A value indicating whether or not managed resources should be released.
/// </param>
protected override void Dispose(Boolean disposing) => base.Dispose(disposing);

/// <summary>
/// When overridden by a derived class, gets a copyright notice which is written to the console at the start of service
/// execution.
/// </summary>
protected override sealed String CopyrightNotice => "Copyright (c) RapidField LLC. All rights reserved.";

/// <summary>
/// When overridden by a derived class, gets a product name associated with the service which is written to the console at
/// the start of service execution.
/// </summary>
protected override sealed String ProductName => "Solid Instruments";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================

using System;

namespace RapidField.SolidInstruments.Example.BeaconService
{
/// <summary>
/// Houses the entry point for the application.
/// </summary>
public static class Program
{
/// <summary>
/// Begins execution of the application.
/// </summary>
/// <param name="args">
/// Command line arguments that are provided at runtime.
/// </param>
public static void Main(String[] args)
{
using var serviceExecutor = new ApplicationServiceExecutor();
serviceExecutor.Execute(args);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
-->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>Solid Instruments contributors</Authors>
<Company>RapidField</Company>
<Copyright>Copyright (c) RapidField LLC. All rights reserved.</Copyright>
<Product>Solid Instruments</Product>
<Description>This project demonstrates a beacon service application utilizing Solid Instruments constructs.</Description>
<Version>$(BuildVersion)</Version>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp3.1\RapidField.SolidInstruments.Example.BeaconService.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp3.1\RapidField.SolidInstruments.Example.BeaconService.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\LICENSE.txt" Link="LICENSE.txt" />
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.7" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RapidField.SolidInstruments.Example.Domain\RapidField.SolidInstruments.Example.Domain.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================

{
"ConnectionStrings": {
"ExampleServiceBus": "amqp://guest:guest@localhost:5672"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ protected override void AddListeners(IMessageListeningProfile listeningProfile,
listeningProfile.AddCommandListener<Commands.ModelState.User.CreateDomainModelCommand, Messages.Command.ModelState.User.CreateDomainModelCommandMessage>();
listeningProfile.AddCommandListener<Commands.ModelState.User.DeleteDomainModelCommand, Messages.Command.ModelState.User.DeleteDomainModelCommandMessage>();
listeningProfile.AddCommandListener<Commands.ModelState.User.UpdateDomainModelCommand, Messages.Command.ModelState.User.UpdateDomainModelCommandMessage>();
listeningProfile.AddCommandListener<Commands.ModelState.UserRole.CreateDomainModelCommand, Messages.Command.ModelState.UserRole.CreateDomainModelCommandMessage>();
listeningProfile.AddCommandListener<Commands.ModelState.UserRole.DeleteDomainModelCommand, Messages.Command.ModelState.UserRole.DeleteDomainModelCommandMessage>();
listeningProfile.AddCommandListener<Commands.ModelState.UserRole.UpdateDomainModelCommand, Messages.Command.ModelState.UserRole.UpdateDomainModelCommandMessage>();

// Add event listeners.
listeningProfile.AddEventListener<Events.ModelState.User.DomainModelCreatedEvent, Messages.Event.ModelState.User.DomainModelCreatedEventMessage>();
listeningProfile.AddEventListener<Events.ModelState.User.DomainModelDeletedEvent, Messages.Event.ModelState.User.DomainModelDeletedEventMessage>();
listeningProfile.AddEventListener<Events.ModelState.User.DomainModelUpdatedEvent, Messages.Event.ModelState.User.DomainModelUpdatedEventMessage>();
listeningProfile.AddEventListener<Events.ModelState.UserRole.DomainModelCreatedEvent, Messages.Event.ModelState.UserRole.DomainModelCreatedEventMessage>();
listeningProfile.AddEventListener<Events.ModelState.UserRole.DomainModelDeletedEvent, Messages.Event.ModelState.UserRole.DomainModelDeletedEventMessage>();
listeningProfile.AddEventListener<Events.ModelState.UserRole.DomainModelUpdatedEvent, Messages.Event.ModelState.UserRole.DomainModelUpdatedEventMessage>();
}
finally
{
Expand Down Expand Up @@ -116,11 +122,37 @@ protected override void OnExecutionStarting(IDependencyScope dependencyScope, IC
{
try
{
var mediator = dependencyScope.Resolve<ICommandMediator>();

// Create or update the database schema.
var databaseContext = dependencyScope.Resolve<DatabaseContext>();
databaseContext.Database.EnsureCreated();
var mediator = dependencyScope.Resolve<ICommandMediator>();
mediator.Process(new Messages.Command.ModelState.User.CreateDomainModelCommandMessage(new Commands.ModelState.User.CreateDomainModelCommand(Models.User.DomainModel.Named.StevenCallahan)));
mediator.Process(new Messages.Command.ModelState.User.CreateDomainModelCommandMessage(new Commands.ModelState.User.CreateDomainModelCommand(Models.User.DomainModel.Named.TomSmith)));

foreach (var domainModel in Models.User.DomainModel.Named.All())
{
mediator.Process(new Messages.Command.ModelState.User.CreateDomainModelCommandMessage(new Commands.ModelState.User.CreateDomainModelCommand(domainModel)));
}

foreach (var domainModel in Models.UserRole.DomainModel.Named.All())
{
mediator.Process(new Messages.Command.ModelState.UserRole.CreateDomainModelCommandMessage(new Commands.ModelState.UserRole.CreateDomainModelCommand(domainModel)));
}

try
{
// Test service bus connectivity.
var pingRequestCorrelationIdentifier = Guid.NewGuid();
var pingResponseMessage = mediator.Process<PingResponseMessage>(new PingRequestMessage(pingRequestCorrelationIdentifier));

if (pingResponseMessage is null || pingResponseMessage.CorrelationIdentifier != pingRequestCorrelationIdentifier)
{
throw new ServiceExectuionException("The service was unable to verify service bus connectivity.");
}
}
catch (CommandHandlingException exception)
{
throw new ServiceExectuionException("The service was unable to verify service bus connectivity. See inner exception.", exception);
}
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netstandard2.1\RapidField.SolidInstruments.Example.Domain.AccessControl.Service.xml</DocumentationFile>
<DocumentationFile>bin\Debug\netcoreapp3.1\RapidField.SolidInstruments.Example.Domain.AccessControl.Service.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netstandard2.1\RapidField.SolidInstruments.Example.Domain.AccessControl.Service.xml</DocumentationFile>
<DocumentationFile>bin\Release\netcoreapp3.1\RapidField.SolidInstruments.Example.Domain.AccessControl.Service.xml</DocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\LICENSE.txt" Link="LICENSE.txt" />
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.7" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RapidField.SolidInstruments.Example.Domain.AccessControl\RapidField.SolidInstruments.Example.Domain.AccessControl.csproj" />
<ProjectReference Include="..\RapidField.SolidInstruments.Example.Domain.AccessControl\RapidField.SolidInstruments.Example.Domain.AccessControl.csproj" />
</ItemGroup>
</Project>
Loading

0 comments on commit 1cca248

Please sign in to comment.