.editorconfig

This commit is contained in:
Mike Phares 2022-11-11 12:29:10 -07:00
parent 94643d7c4d
commit 59db921a65
4 changed files with 35 additions and 17 deletions

View File

@ -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

1
.vscode/format-report.json vendored Normal file
View File

@ -0,0 +1 @@
[]

View File

@ -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;
}

View File

@ -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<Worker>();
})
.UseWindowsService()
.Build();
internal class Program
{
await host.RunAsync();
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<Worker>();
})
.UseWindowsService()
.Build();
await host.RunAsync();
}
}