Skip to content

Commit

Permalink
Merge branch 'main' into BR-13-Socket-Timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
davewalker5 committed Aug 27, 2023
2 parents 593cc00 + 8c7da6d commit ad2d923
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
## SQLite Database

### Database Schema
- Tracking records are written to a single table, called AIRCRAFT, summarising the detail from the messages received for a given aircraft:
- Tracking records are written to a single table, called AIRCRAFT, with each row summarising the detail from the messages received for a given aircraft:

![Tracking Table](Diagrams/database.png)

Expand All @@ -107,7 +107,7 @@ dotnet tool install --global dotnet-ef
- Run the following command, making sure to use the path separator appropriate for your OS:

```bash
dotnet ef database update -s ../BaseStationReader.Manager/BaseStationReader.Manager.csproj
dotnet ef database update -s ../BaseStationReader.Terminal/BaseStationReader.Terminal.csproj
```

- If the database doesn't exist, it will create it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@
<ReleaseVersion>1.11.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace BaseStationReader.Terminal
namespace BaseStationReader.Entities.Config
{
internal class ApplicationSettings
public class ApplicationSettings
{
public string Host { get; set; } = "";
public int Port { get; set; }
Expand Down
25 changes: 25 additions & 0 deletions src/BaseStationReader.Logic/ConfigReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using BaseStationReader.Entities.Config;
using Microsoft.Extensions.Configuration;
using System.Diagnostics.CodeAnalysis;

namespace BaseStationReader.Logic
{
[ExcludeFromCodeCoverage]
public class ConfigReader
{
/// <summary>
/// Load and return the application settings from the named JSON-format application settings file
/// </summary>
/// <returns></returns>
public ApplicationSettings? Read(string jsonFileName)
{
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile(jsonFileName)
.Build();

IConfigurationSection section = configuration.GetSection("ApplicationSettings");
var settings = section.Get<ApplicationSettings>();
return settings;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Spectre.Console" Version="0.47.0" />
Expand Down
12 changes: 3 additions & 9 deletions src/BaseStationReader.Terminal/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using BaseStationReader.Data;
using BaseStationReader.Entities.Config;
using BaseStationReader.Entities.Events;
using BaseStationReader.Entities.Interfaces;
using BaseStationReader.Entities.Messages;
using BaseStationReader.Entities.Tracking;
using BaseStationReader.Logic;
using Microsoft.Extensions.Configuration;
using Serilog;
using Spectre.Console;
using System;
using System.Diagnostics;
using System.Reflection;

Expand All @@ -21,13 +20,8 @@ public class Program

public static async Task Main(string[] args)
{
// Load the application settings
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();

IConfigurationSection section = configuration.GetSection("ApplicationSettings");
var settings = section.Get<ApplicationSettings>();
// Read the application config
ApplicationSettings? settings = new ConfigReader().Read("appsettings.json");

// Configure the log file
#pragma warning disable CS8602
Expand Down

0 comments on commit ad2d923

Please sign in to comment.