-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#371 Introduce new example projects.
- Loading branch information
1 parent
743cfe6
commit 60a9539
Showing
37 changed files
with
1,239 additions
and
42 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
42 changes: 42 additions & 0 deletions
42
...eld.SolidInstruments.Example.Domain.AccessControl.Service/ApplicationDependencyPackage.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,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) | ||
}; | ||
} | ||
} |
128 changes: 128 additions & 0 deletions
128
...Field.SolidInstruments.Example.Domain.AccessControl.Service/ApplicationServiceExecutor.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,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"; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
example/RapidField.SolidInstruments.Example.Domain.AccessControl.Service/Program.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 @@ | ||
// ================================================================================================================================= | ||
// 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"; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
example/RapidField.SolidInstruments.Example.Domain.AccessControl.Service/README.md
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,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. |
42 changes: 42 additions & 0 deletions
42
...ssControl.Service/RapidField.SolidInstruments.Example.Domain.AccessControl.Service.csproj
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,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> |
16 changes: 16 additions & 0 deletions
16
example/RapidField.SolidInstruments.Example.Domain.AccessControl.Service/appsettings.json
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,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" | ||
} | ||
} | ||
} |
Oops, something went wrong.