From 59db921a658c175ef82b463c744e9ae7e6fd1f79 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Fri, 11 Nov 2022 12:29:10 -0700 Subject: [PATCH] .editorconfig --- .editorconfig | 1 + .vscode/format-report.json | 1 + Models/Binder/AppSettings.cs | 24 ++++++++++++++++-------- Program.cs | 26 +++++++++++++++++--------- 4 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 .vscode/format-report.json diff --git a/.editorconfig b/.editorconfig index 3856cdf..56b46ef 100644 --- a/.editorconfig +++ b/.editorconfig @@ -83,6 +83,7 @@ dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant. dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2"); dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary +dotnet_diagnostic.IDE0031.severity = warning # Use null propagation (IDE0031) dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed dotnet_diagnostic.IDE0049.severity = warning # Use language keywords instead of framework type names for type references (IDE0049) dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter diff --git a/.vscode/format-report.json b/.vscode/format-report.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/.vscode/format-report.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/Models/Binder/AppSettings.cs b/Models/Binder/AppSettings.cs index 7147442..d4482de 100644 --- a/Models/Binder/AppSettings.cs +++ b/Models/Binder/AppSettings.cs @@ -28,14 +28,22 @@ public class AppSettings private static Models.AppSettings Get(AppSettings appSettings) { Models.AppSettings result; - if (appSettings.DateFormat is null) throw new NullReferenceException(nameof(DateFormat)); - if (appSettings.Directory is null) throw new NullReferenceException(nameof(Directory)); - if (appSettings.LogFilter is null) throw new NullReferenceException(nameof(LogFilter)); - if (appSettings.MessageFilters is null) throw new NullReferenceException(nameof(MessageFilters)); - if (appSettings.MillisecondsDelay is null) throw new NullReferenceException(nameof(MillisecondsDelay)); - if (appSettings.MonitorApplicationResource is null) throw new NullReferenceException(nameof(MonitorApplicationResource)); - if (appSettings.MonitorApplicationSite is null) throw new NullReferenceException(nameof(MonitorApplicationSite)); - if (appSettings.RollingMinutes is null) throw new NullReferenceException(nameof(RollingMinutes)); + if (appSettings.DateFormat is null) + throw new NullReferenceException(nameof(DateFormat)); + if (appSettings.Directory is null) + throw new NullReferenceException(nameof(Directory)); + if (appSettings.LogFilter is null) + throw new NullReferenceException(nameof(LogFilter)); + if (appSettings.MessageFilters is null) + throw new NullReferenceException(nameof(MessageFilters)); + if (appSettings.MillisecondsDelay is null) + throw new NullReferenceException(nameof(MillisecondsDelay)); + if (appSettings.MonitorApplicationResource is null) + throw new NullReferenceException(nameof(MonitorApplicationResource)); + if (appSettings.MonitorApplicationSite is null) + throw new NullReferenceException(nameof(MonitorApplicationSite)); + if (appSettings.RollingMinutes is null) + throw new NullReferenceException(nameof(RollingMinutes)); result = new(appSettings.DateFormat, appSettings.Directory, appSettings.LogFilter, appSettings.MessageFilters, appSettings.MonitorApplicationResource, appSettings.MonitorApplicationSite, appSettings.MillisecondsDelay.Value, appSettings.RollingMinutes.Value); return result; } diff --git a/Program.cs b/Program.cs index 74d5083..1c577ce 100644 --- a/Program.cs +++ b/Program.cs @@ -1,12 +1,20 @@ using WinLog; -IHost host = Host.CreateDefaultBuilder(args) - .ConfigureServices((hostContext, services) => - { - _ = services.AddSingleton(WinLog.Models.Binder.AppSettings.Get(hostContext.Configuration)); - _ = services.AddHostedService(); - }) - .UseWindowsService() - .Build(); +internal class Program +{ -await host.RunAsync(); \ No newline at end of file + private static async Task Main(string[] args) + { + IHost host = Host.CreateDefaultBuilder(args) + .ConfigureServices((hostContext, services) => + { + _ = services.AddSingleton(WinLog.Models.Binder.AppSettings.Get(hostContext.Configuration)); + _ = services.AddHostedService(); + }) + .UseWindowsService() + .Build(); + + await host.RunAsync(); + } + +} \ No newline at end of file