Serilog
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Phares.Shared;
|
||||
using Serilog;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using View_by_Distance.Drag_Drop.Models;
|
||||
@ -14,7 +13,6 @@ namespace View_by_Distance.Drag_Drop;
|
||||
public partial class DragDropSearch : Form
|
||||
{
|
||||
|
||||
private readonly ILogger _Logger;
|
||||
private readonly TextBox _TextBox;
|
||||
private readonly AppSettings _AppSettings;
|
||||
private readonly ProgressBar _ProgressBar;
|
||||
@ -29,14 +27,12 @@ public partial class DragDropSearch : Form
|
||||
public DragDropSearch()
|
||||
{
|
||||
InitializeComponent();
|
||||
ILogger logger;
|
||||
_IdToItem = new();
|
||||
AppSettings appSettings;
|
||||
string workingDirectory;
|
||||
IsEnvironment isEnvironment;
|
||||
Models.Configuration configuration;
|
||||
IConfigurationRoot configurationRoot;
|
||||
LoggerConfiguration loggerConfiguration = new();
|
||||
Property.Models.Configuration propertyConfiguration;
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
|
||||
@ -51,14 +47,9 @@ public partial class DragDropSearch : Form
|
||||
throw new Exception("Working path name must have parentDirectory value!");
|
||||
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
|
||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
|
||||
Log.Logger = loggerConfiguration.CreateLogger();
|
||||
logger = Log.ForContext<DragDropSearch>();
|
||||
propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||
configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||
(_, _, string resizeFileNameExtension) = C_Resize.GetTuple(configuration.OutputExtension, configuration.OutputQuality);
|
||||
logger.Information("Complete");
|
||||
_Logger = logger;
|
||||
_AppSettings = appSettings;
|
||||
_Configuration = configuration;
|
||||
_IsEnvironment = isEnvironment;
|
||||
@ -128,14 +119,6 @@ public partial class DragDropSearch : Form
|
||||
continue;
|
||||
_IdToItem.Add(item.Property.Id.Value, item);
|
||||
}
|
||||
if (_Logger is null)
|
||||
throw new NullReferenceException(nameof(_Logger));
|
||||
_Logger.Debug((_AppSettings is null).ToString());
|
||||
_Logger.Debug((_Configuration is null).ToString());
|
||||
_Logger.Debug((_IsEnvironment is null).ToString());
|
||||
_Logger.Debug((_WorkingDirectory is null).ToString());
|
||||
_Logger.Debug((_ConfigurationRoot is null).ToString());
|
||||
_Logger.Debug((_PropertyConfiguration is null).ToString());
|
||||
}
|
||||
|
||||
public static string? GetFaceEncoding(string file)
|
||||
@ -179,8 +162,6 @@ public partial class DragDropSearch : Form
|
||||
{
|
||||
Text = item.ImageFileHolder.Name;
|
||||
_TextBox.Text = item.ImageFileHolder.FullName;
|
||||
if (item.ImageFileHolder.DirectoryName is not null)
|
||||
_Logger.Information(item.ImageFileHolder.DirectoryName);
|
||||
if (!string.IsNullOrEmpty(item.ImageFileHolder.DirectoryName))
|
||||
_ = Process.Start("explorer.exe", string.Concat("\"", item.ImageFileHolder.DirectoryName, "\""));
|
||||
}
|
||||
|
Reference in New Issue
Block a user