Skip to content

Commit

Permalink
#371 Introduce new example projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjstone committed Aug 22, 2020
1 parent 743cfe6 commit 60a9539
Show file tree
Hide file tree
Showing 37 changed files with 1,239 additions and 42 deletions.
9 changes: 8 additions & 1 deletion RapidField.SolidInstruments.sln
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RapidField.SolidInstruments
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RapidField.SolidInstruments.DataAccess.DotNetNative.Ef", "src\RapidField.SolidInstruments.DataAccess.DotNetNative.Ef\RapidField.SolidInstruments.DataAccess.DotNetNative.Ef.csproj", "{F20759D5-D39D-4C31-8A23-AEAA606776E6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RapidField.SolidInstruments.Example.Domain.AccessControl", "example\RapidField.SolidInstruments.Example.Domain.AccessControl\RapidField.SolidInstruments.Example.Domain.AccessControl.csproj", "{7B185E3A-3A26-4188-9FB4-DED7E4EF5C3D}"
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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -619,6 +621,10 @@ Global
{7B185E3A-3A26-4188-9FB4-DED7E4EF5C3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B185E3A-3A26-4188-9FB4-DED7E4EF5C3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B185E3A-3A26-4188-9FB4-DED7E4EF5C3D}.Release|Any CPU.Build.0 = Release|Any CPU
{77026FD0-F0DC-48B8-A678-0E67BDCC29EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -693,6 +699,7 @@ Global
{266AC8D7-BDA0-42B0-B473-9025EDEB8DF8} = {F58E05BE-9DC6-41B4-8324-C006F6CE7CC7}
{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}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {834FCFB0-DA00-4ABD-9424-6FE1398A9F6E}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// =================================================================================================================================
// 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.InversionOfControl;
using RapidField.SolidInstruments.InversionOfControl.DotNetNative;
using System.Collections.Generic;

namespace RapidField.SolidInstruments.Example.Domain.AccessControl.Service
{
/// <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 DatabaseContextDependencyModule(applicationConfiguration),
new ServiceBusDependencyModule(applicationConfiguration)
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// =================================================================================================================================
// 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.Core;
using RapidField.SolidInstruments.InversionOfControl;
using RapidField.SolidInstruments.Messaging.DotNetNative.Service;
using RapidField.SolidInstruments.Messaging.Service;
using RapidField.SolidInstruments.Service;
using System;
using System.IO;

namespace RapidField.SolidInstruments.Example.Domain.AccessControl.Service
{
/// <summary>
/// Prepares for and performs execution of the AccessControl domain service.
/// </summary>
public sealed class ApplicationServiceExecutor : DotNetNativeMessagingServiceExecutor<ApplicationDependencyPackage>
{
/// <summary>
/// Initializes a new instance of the <see cref="ApplicationServiceExecutor" /> class.
/// </summary>
/// <param name="serviceName">
/// The name of the service.
/// </param>
/// <exception cref="ArgumentEmptyException">
/// <paramref name="serviceName" /> is empty.
/// </exception>
/// <exception cref="ArgumentNullException">
/// <paramref name="serviceName" /> is <see langword="null" />.
/// </exception>
public ApplicationServiceExecutor(String serviceName)
: base(serviceName)
{
return;
}

/// <summary>
/// Adds message listeners to the service.
/// </summary>
/// <param name="listeningProfile">
/// An object that is used to add listeners.
/// </param>
/// <param name="applicationConfiguration">
/// Configuration information for the service application.
/// </param>
/// <param name="commandLineArguments">
/// Command line arguments that are provided at runtime, if any.
/// </param>
protected override void AddListeners(IMessageListeningProfile listeningProfile, IConfiguration applicationConfiguration, String[] commandLineArguments)
{
try
{
listeningProfile.AddExceptionRaisedEventListener();
listeningProfile.AddHeartbeatListener();
listeningProfile.AddPingRequestListener();
}
finally
{
base.AddListeners(listeningProfile, applicationConfiguration, commandLineArguments);
}
}

/// <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>
/// Performs startup operations for the service.
/// </summary>
/// <param name="dependencyScope">
/// A scope that is used to resolve service dependencies.
/// </param>
/// <param name="applicationConfiguration">
/// Configuration information for the service application.
/// </param>
/// <param name="executionLifetime">
/// An object that provides control over execution lifetime.
/// </param>
protected override void OnExecutionStarting(IDependencyScope dependencyScope, IConfiguration applicationConfiguration, IServiceExecutionLifetime executionLifetime)
{
try
{
var databaseContext = dependencyScope.Resolve<DatabaseContext>();
databaseContext.Database.EnsureCreated();
}
finally
{
base.OnExecutionStarting(dependencyScope, applicationConfiguration, executionLifetime);
}
}

/// <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,33 @@
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================

using System;
using System.Diagnostics;

namespace RapidField.SolidInstruments.Example.Domain.AccessControl.Service
{
/// <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(ServiceName);
serviceExecutor.Execute(args);
}

/// <summary>
/// Represents the name of the service that is hosted by this application.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private const String ServiceName = "AccessControl Service";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
-->

[![Solid Instruments](../../SolidInstruments.Logo.Color.Transparent.500w.png)](../../README.md)
- - -

# RapidField.SolidInstruments.Example.Domain.AccessControl.Service

This document describes the purpose of the [`RapidField.SolidInstruments.Example.Domain.AccessControl.Service`]() project.

## Purpose

This project demonstrates an access control domain service utilizing the **Solid Instruments** [data access](../../src/RapidField.SolidInstruments.DataAccess/README.md) and [messaging](../../src/RapidField.SolidInstruments.Messaging/README.md) constructs.

## License

[![License](https://img.shields.io/github/license/rapidfield/solid-instruments?style=flat&color=lightseagreen&label=license&logo=open-access&logoColor=lightgrey)](../../LICENSE.txt)

**Solid Instruments** is [MIT-licensed](https://en.wikipedia.org/wiki/MIT_License). Review the [license terms](../../LICENSE.txt) for more information.

<br />

- - -

<br />

[![RapidField](../../RapidField.Logo.Color.Black.Transparent.200w.png)](https://www.rapidfield.com)

###### Copyright (c) RapidField LLC. All rights reserved. "RapidField" and "Solid Instruments" are trademarks of RapidField LLC.
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 an access control 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\netstandard2.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>
<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.AccessControl\RapidField.SolidInstruments.Example.Domain.AccessControl.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================

{
"ConnectionStrings": {
"AccessControl": "Server=(LocalDB)\\MSSQLLocalDB;Database=AccessControl;Trusted_Connection=True;",
"ExampleServiceBus": "amqp://guest:guest@localhost:5672"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}
Loading

0 comments on commit 60a9539

Please sign in to comment.