After testing E_Distance.SaveGroupedFaceEncodings
This commit is contained in:
35
TestsWithFaceRecognitionDotNet/Models/AppSettings.cs
Normal file
35
TestsWithFaceRecognitionDotNet/Models/AppSettings.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.TestsWithFaceRecognitionDotNet.Models;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
protected string _Company;
|
||||
protected string _WorkingDirectoryName;
|
||||
protected int? _MaxDegreeOfParallelism;
|
||||
public string Company => _Company;
|
||||
public string WorkingDirectoryName => _WorkingDirectoryName;
|
||||
public int? MaxDegreeOfParallelism => _MaxDegreeOfParallelism;
|
||||
|
||||
// public AppSettings()
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string company, string workingDirectoryName, int? maxDegreeOfParallelism)
|
||||
{
|
||||
_Company = company;
|
||||
_WorkingDirectoryName = workingDirectoryName;
|
||||
_MaxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
26
TestsWithFaceRecognitionDotNet/Models/Binder/AppSettings.cs
Normal file
26
TestsWithFaceRecognitionDotNet/Models/Binder/AppSettings.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.TestsWithFaceRecognitionDotNet.Models.Binder;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
[Display(Name = "Company"), Required] public string Company { get; set; }
|
||||
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
|
||||
[Display(Name = "Max Degree Of Parallelism"), Required] public int? MaxDegreeOfParallelism { get; set; }
|
||||
|
||||
public AppSettings()
|
||||
{
|
||||
Company = string.Empty;
|
||||
WorkingDirectoryName = string.Empty;
|
||||
MaxDegreeOfParallelism = -1;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
103
TestsWithFaceRecognitionDotNet/Models/Binder/Configuration.cs
Normal file
103
TestsWithFaceRecognitionDotNet/Models/Binder/Configuration.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.TestsWithFaceRecognitionDotNet.Models.Binder;
|
||||
|
||||
public class Configuration
|
||||
{
|
||||
|
||||
[Display(Name = "Check Json For Distance Results"), Required] public bool? CheckJsonForDistanceResults { get; set; }
|
||||
[Display(Name = "CrossDirectory Max Items In Distance Collection"), Required] public int? CrossDirectoryMaxItemsInDistanceCollection { get; set; }
|
||||
[Display(Name = "Distance Factor"), Required] public int? DistanceFactor { get; set; }
|
||||
[Display(Name = "Force Metadata Last Write Time to Creation Time"), Required] public bool? ForceMetadataLastWriteTimeToCreationTime { get; set; }
|
||||
[Display(Name = "Force Resize Last Write Time to Creation Time"), Required] public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
|
||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
||||
[Display(Name = "Ignore Relative Paths"), Required] public string[] IgnoreRelativePaths { get; set; }
|
||||
[Display(Name = "Julie Phares Copy Birthdays"), Required] public string[] JuliePhares { get; set; }
|
||||
[Display(Name = "Load Or Create Then Save Directory Distance Results"), Required] public string[] LoadOrCreateThenSaveDirectoryDistanceResultsForOutputResolutions { get; set; }
|
||||
[Display(Name = "Load Or Create Then Save Distance Results"), Required] public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions { get; set; }
|
||||
[Display(Name = "Load Or Create Then Save Image Faces Results"), Required] public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions { get; set; }
|
||||
[Display(Name = "Load Or Create Then Save Index"), Required] public bool? LoadOrCreateThenSaveIndex { get; set; }
|
||||
[Display(Name = "Location Confidence Factor"), Required] public int? LocationConfidenceFactor { get; set; }
|
||||
[Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; }
|
||||
[Display(Name = "Max Items In Distance Collection"), Required] public int? MaxItemsInDistanceCollection { get; set; }
|
||||
[Display(Name = "Mixed Year Relative Paths"), Required] public string[] MixedYearRelativePaths { get; set; }
|
||||
[Display(Name = "Model Directory"), Required] public string ModelDirectory { get; set; }
|
||||
[Display(Name = "Model Name"), Required] public string ModelName { get; set; }
|
||||
[Display(Name = "Number Jitters"), Required] public int? NumberOfJitters { get; set; }
|
||||
[Display(Name = "Number of Times To Up Sample"), Required] public int? NumberOfTimesToUpsample { get; set; }
|
||||
[Display(Name = "Output Extension"), Required] public string OutputExtension { get; set; }
|
||||
[Display(Name = "Output Quality"), Required] public int? OutputQuality { get; set; }
|
||||
[Display(Name = "Output Resolutions"), Required] public string[] OutputResolutions { get; set; }
|
||||
[Display(Name = "Override For Face Images"), Required] public bool? OverrideForFaceImages { get; set; }
|
||||
[Display(Name = "Override For Face Landmark Images"), Required] public bool? OverrideForFaceLandmarkImages { get; set; }
|
||||
[Display(Name = "Override For Resize Images"), Required] public bool? OverrideForResizeImages { get; set; }
|
||||
[Display(Name = "Padding Loops"), Required] public int? PaddingLoops { get; set; }
|
||||
[Display(Name = "Predictor Model Name"), Required] public string PredictorModelName { get; set; }
|
||||
[Display(Name = "Properties Changed For Distance"), Required] public bool? PropertiesChangedForDistance { get; set; }
|
||||
[Display(Name = "Properties Changed For Faces"), Required] public bool? PropertiesChangedForFaces { get; set; }
|
||||
[Display(Name = "Properties Changed For Index"), Required] public bool? PropertiesChangedForIndex { get; set; }
|
||||
[Display(Name = "Properties Changed For Metadata"), Required] public bool? PropertiesChangedForMetadata { get; set; }
|
||||
[Display(Name = "Properties Changed For Resize"), Required] public bool? PropertiesChangedForResize { get; set; }
|
||||
[Display(Name = "Property Configuration"), Required] public Property.Models.Configuration? PropertyConfiguration { get; set; }
|
||||
[Display(Name = "Reverse"), Required] public bool? Reverse { get; set; }
|
||||
[Display(Name = "Save Face Landmark For Output Resolutions"), Required] public string[] SaveFaceLandmarkForOutputResolutions { get; set; }
|
||||
[Display(Name = "Save Full Year Of Random Files"), Required] public bool? SaveFullYearOfRandomFiles { get; set; }
|
||||
[Display(Name = "Save Resized Subfiles"), Required] public bool? SaveResizedSubfiles { get; set; }
|
||||
[Display(Name = "Save Shortcuts"), Required] public string[] SaveShortcutsForOutputResolutions { get; set; }
|
||||
[Display(Name = "Skip Search"), Required] public bool? SkipSearch { get; set; }
|
||||
[Display(Name = "Test Distance Results"), Required] public bool? TestDistanceResults { get; set; }
|
||||
[Display(Name = "Valid Resolutions"), Required] public string[] ValidResolutions { get; set; }
|
||||
|
||||
public Configuration()
|
||||
{
|
||||
CheckJsonForDistanceResults = null;
|
||||
CrossDirectoryMaxItemsInDistanceCollection = null;
|
||||
DistanceFactor = null;
|
||||
ForceMetadataLastWriteTimeToCreationTime = null;
|
||||
ForceResizeLastWriteTimeToCreationTime = null;
|
||||
IgnoreExtensions = Array.Empty<string>();
|
||||
IgnoreRelativePaths = Array.Empty<string>();
|
||||
JuliePhares = Array.Empty<string>();
|
||||
LoadOrCreateThenSaveDirectoryDistanceResultsForOutputResolutions = Array.Empty<string>();
|
||||
LoadOrCreateThenSaveDistanceResultsForOutputResolutions = Array.Empty<string>();
|
||||
LoadOrCreateThenSaveImageFacesResultsForOutputResolutions = Array.Empty<string>();
|
||||
LoadOrCreateThenSaveIndex = null;
|
||||
LocationConfidenceFactor = null;
|
||||
MappedMaxIndex = null;
|
||||
MaxItemsInDistanceCollection = null;
|
||||
MixedYearRelativePaths = Array.Empty<string>();
|
||||
ModelDirectory = string.Empty;
|
||||
ModelName = string.Empty;
|
||||
NumberOfJitters = null;
|
||||
NumberOfTimesToUpsample = null;
|
||||
OutputExtension = string.Empty;
|
||||
OutputQuality = null;
|
||||
OutputResolutions = Array.Empty<string>();
|
||||
OverrideForFaceImages = null;
|
||||
OverrideForFaceLandmarkImages = null;
|
||||
OverrideForResizeImages = null;
|
||||
PaddingLoops = null;
|
||||
PredictorModelName = string.Empty;
|
||||
PropertiesChangedForDistance = null;
|
||||
PropertiesChangedForFaces = null;
|
||||
PropertiesChangedForIndex = null;
|
||||
PropertiesChangedForMetadata = null;
|
||||
PropertiesChangedForResize = null;
|
||||
Reverse = null;
|
||||
SaveFaceLandmarkForOutputResolutions = Array.Empty<string>();
|
||||
SaveFullYearOfRandomFiles = null;
|
||||
SaveResizedSubfiles = null;
|
||||
SaveShortcutsForOutputResolutions = Array.Empty<string>();
|
||||
SkipSearch = null;
|
||||
TestDistanceResults = null;
|
||||
ValidResolutions = Array.Empty<string>();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
151
TestsWithFaceRecognitionDotNet/Models/Configuration.cs
Normal file
151
TestsWithFaceRecognitionDotNet/Models/Configuration.cs
Normal file
@ -0,0 +1,151 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.TestsWithFaceRecognitionDotNet.Models;
|
||||
|
||||
public class Configuration
|
||||
{
|
||||
|
||||
protected readonly bool? _CheckJsonForDistanceResults;
|
||||
protected readonly int? _CrossDirectoryMaxItemsInDistanceCollection;
|
||||
protected readonly int? _DistanceFactor;
|
||||
protected readonly bool? _ForceMetadataLastWriteTimeToCreationTime;
|
||||
protected readonly bool? _ForceResizeLastWriteTimeToCreationTime;
|
||||
protected readonly string[] _IgnoreExtensions;
|
||||
protected readonly string[] _IgnoreRelativePaths;
|
||||
protected readonly string[] _JuliePhares;
|
||||
protected readonly string[] _LoadOrCreateThenSaveDirectoryDistanceResultsForOutputResolutions;
|
||||
protected readonly string[] _LoadOrCreateThenSaveDistanceResultsForOutputResolutions;
|
||||
protected readonly string[] _LoadOrCreateThenSaveImageFacesResultsForOutputResolutions;
|
||||
protected readonly bool? _LoadOrCreateThenSaveIndex;
|
||||
protected readonly int? _LocationConfidenceFactor;
|
||||
protected readonly int? _MappedMaxIndex;
|
||||
protected readonly int? _MaxItemsInDistanceCollection;
|
||||
protected readonly string[] _MixedYearRelativePaths;
|
||||
protected readonly string _ModelDirectory;
|
||||
protected readonly string _ModelName;
|
||||
protected readonly int? _NumberOfJitters;
|
||||
protected readonly int? _NumberOfTimesToUpsample;
|
||||
protected readonly string _OutputExtension;
|
||||
protected readonly int? _OutputQuality;
|
||||
protected readonly string[] _OutputResolutions;
|
||||
protected readonly bool? _OverrideForFaceImages;
|
||||
protected readonly bool? _OverrideForFaceLandmarkImages;
|
||||
protected readonly bool? _OverrideForResizeImages;
|
||||
protected readonly int? _PaddingLoops;
|
||||
protected readonly string _PredictorModelName;
|
||||
protected readonly bool? _PropertiesChangedForDistance;
|
||||
protected readonly bool? _PropertiesChangedForFaces;
|
||||
protected readonly bool? _PropertiesChangedForIndex;
|
||||
protected readonly bool? _PropertiesChangedForMetadata;
|
||||
protected readonly bool? _PropertiesChangedForResize;
|
||||
protected Property.Models.Configuration? _PropertyConfiguration;
|
||||
protected readonly bool? _Reverse;
|
||||
protected readonly string[] _SaveFaceLandmarkForOutputResolutions;
|
||||
protected readonly bool? _SaveFullYearOfRandomFiles;
|
||||
protected readonly bool? _SaveResizedSubfiles;
|
||||
protected readonly string[] _SaveShortcutsForOutputResolutions;
|
||||
protected readonly bool? _SkipSearch;
|
||||
protected readonly bool? _TestDistanceResults;
|
||||
protected readonly string[] _ValidResolutions;
|
||||
public bool? CheckJsonForDistanceResults => _CheckJsonForDistanceResults;
|
||||
public int? CrossDirectoryMaxItemsInDistanceCollection => _CrossDirectoryMaxItemsInDistanceCollection;
|
||||
public int? DistanceFactor => _DistanceFactor;
|
||||
public bool? ForceMetadataLastWriteTimeToCreationTime => _ForceMetadataLastWriteTimeToCreationTime;
|
||||
public bool? ForceResizeLastWriteTimeToCreationTime => _ForceResizeLastWriteTimeToCreationTime;
|
||||
public string[] IgnoreExtensions => _IgnoreExtensions;
|
||||
public string[] IgnoreRelativePaths => _IgnoreRelativePaths;
|
||||
public string[] JuliePhares => _JuliePhares;
|
||||
public string[] LoadOrCreateThenSaveDirectoryDistanceResultsForOutputResolutions => _LoadOrCreateThenSaveDirectoryDistanceResultsForOutputResolutions;
|
||||
public string[] LoadOrCreateThenSaveDistanceResultsForOutputResolutions => _LoadOrCreateThenSaveDistanceResultsForOutputResolutions;
|
||||
public string[] LoadOrCreateThenSaveImageFacesResultsForOutputResolutions => _LoadOrCreateThenSaveImageFacesResultsForOutputResolutions;
|
||||
public bool? LoadOrCreateThenSaveIndex => _LoadOrCreateThenSaveIndex;
|
||||
public int? LocationConfidenceFactor => _LocationConfidenceFactor;
|
||||
public int? MappedMaxIndex => _MappedMaxIndex;
|
||||
public int? MaxItemsInDistanceCollection => _MaxItemsInDistanceCollection;
|
||||
public string[] MixedYearRelativePaths => _MixedYearRelativePaths;
|
||||
public string ModelDirectory => _ModelDirectory;
|
||||
public string ModelName => _ModelName;
|
||||
public int? NumberOfJitters => _NumberOfJitters;
|
||||
public int? NumberOfTimesToUpsample => _NumberOfTimesToUpsample;
|
||||
public string OutputExtension => _OutputExtension;
|
||||
public int? OutputQuality => _OutputQuality;
|
||||
public string[] OutputResolutions => _OutputResolutions;
|
||||
public bool? OverrideForFaceImages => _OverrideForFaceImages;
|
||||
public bool? OverrideForFaceLandmarkImages => _OverrideForFaceLandmarkImages;
|
||||
public bool? OverrideForResizeImages => _OverrideForResizeImages;
|
||||
public int? PaddingLoops => _PaddingLoops;
|
||||
public string PredictorModelName => _PredictorModelName;
|
||||
public bool? PropertiesChangedForDistance => _PropertiesChangedForDistance;
|
||||
public bool? PropertiesChangedForFaces => _PropertiesChangedForFaces;
|
||||
public bool? PropertiesChangedForIndex => _PropertiesChangedForIndex;
|
||||
public bool? PropertiesChangedForMetadata => _PropertiesChangedForMetadata;
|
||||
public bool? PropertiesChangedForResize => _PropertiesChangedForResize;
|
||||
public Property.Models.Configuration? PropertyConfiguration => _PropertyConfiguration;
|
||||
public bool? Reverse => _Reverse;
|
||||
public string[] SaveFaceLandmarkForOutputResolutions => _SaveFaceLandmarkForOutputResolutions;
|
||||
public bool? SaveFullYearOfRandomFiles => _SaveFullYearOfRandomFiles;
|
||||
public bool? SaveResizedSubfiles => _SaveResizedSubfiles;
|
||||
public string[] SaveShortcutsForOutputResolutions => _SaveShortcutsForOutputResolutions;
|
||||
public bool? SkipSearch => _SkipSearch;
|
||||
public bool? TestDistanceResults => _TestDistanceResults;
|
||||
public string[] ValidResolutions => _ValidResolutions;
|
||||
|
||||
[JsonConstructor]
|
||||
public Configuration(bool? checkJsonForDistanceResults, int? crossDirectoryMaxItemsInDistanceCollection, int? distanceFactor, bool? forceMetadataLastWriteTimeToCreationTime, bool? forceResizeLastWriteTimeToCreationTime, string[] ignoreExtensions, string[] ignoreRelativePaths, string[] juliePhares, string[] loadOrCreateThenSaveDirectoryDistanceResultsForOutputResolutions, string[] loadOrCreateThenSaveDistanceResultsForOutputResolutions, string[] loadOrCreateThenSaveImageFacesResultsForOutputResolutions, bool? loadOrCreateThenSaveIndex, int? locationConfidenceFactor, int? mappedMaxIndex, int? maxItemsInDistanceCollection, string[] mixedYearRelativePaths, string modelDirectory, string modelName, int? numberOfJitters, int? numberOfTimesToUpsample, string outputExtension, int? outputQuality, string[] outputResolutions, bool? overrideForFaceImages, bool? overrideForFaceLandmarkImages, bool? overrideForResizeImages, int? paddingLoops, string predictorModelName, bool? propertiesChangedForDistance, bool? propertiesChangedForFaces, bool? propertiesChangedForIndex, bool? propertiesChangedForMetadata, bool? propertiesChangedForResize, Property.Models.Configuration? propertyConfiguration, bool? reverse, string[] saveFaceLandmarkForOutputResolutions, bool? saveFullYearOfRandomFiles, bool? saveResizedSubfiles, string[] saveShortcutsForOutputResolutions, bool? skipSearch, bool? testDistanceResults, string[] validResolutions)
|
||||
{
|
||||
_CheckJsonForDistanceResults = checkJsonForDistanceResults;
|
||||
_CrossDirectoryMaxItemsInDistanceCollection = crossDirectoryMaxItemsInDistanceCollection;
|
||||
_DistanceFactor = distanceFactor;
|
||||
_ForceMetadataLastWriteTimeToCreationTime = forceMetadataLastWriteTimeToCreationTime;
|
||||
_ForceResizeLastWriteTimeToCreationTime = forceResizeLastWriteTimeToCreationTime;
|
||||
_IgnoreExtensions = ignoreExtensions;
|
||||
_IgnoreRelativePaths = ignoreRelativePaths;
|
||||
_JuliePhares = juliePhares;
|
||||
_LoadOrCreateThenSaveDirectoryDistanceResultsForOutputResolutions = loadOrCreateThenSaveDirectoryDistanceResultsForOutputResolutions;
|
||||
_LoadOrCreateThenSaveDistanceResultsForOutputResolutions = loadOrCreateThenSaveDistanceResultsForOutputResolutions;
|
||||
_LoadOrCreateThenSaveImageFacesResultsForOutputResolutions = loadOrCreateThenSaveImageFacesResultsForOutputResolutions;
|
||||
_LoadOrCreateThenSaveIndex = loadOrCreateThenSaveIndex;
|
||||
_LocationConfidenceFactor = locationConfidenceFactor;
|
||||
_MappedMaxIndex = mappedMaxIndex;
|
||||
_MaxItemsInDistanceCollection = maxItemsInDistanceCollection;
|
||||
_MixedYearRelativePaths = mixedYearRelativePaths;
|
||||
_ModelDirectory = modelDirectory;
|
||||
_ModelName = modelName;
|
||||
_NumberOfJitters = numberOfJitters;
|
||||
_NumberOfTimesToUpsample = numberOfTimesToUpsample;
|
||||
_OutputExtension = outputExtension;
|
||||
_OutputQuality = outputQuality;
|
||||
_OutputResolutions = outputResolutions;
|
||||
_OverrideForFaceImages = overrideForFaceImages;
|
||||
_OverrideForFaceLandmarkImages = overrideForFaceLandmarkImages;
|
||||
_OverrideForResizeImages = overrideForResizeImages;
|
||||
_PaddingLoops = paddingLoops;
|
||||
_PredictorModelName = predictorModelName;
|
||||
_PropertiesChangedForDistance = propertiesChangedForDistance;
|
||||
_PropertiesChangedForFaces = propertiesChangedForFaces;
|
||||
_PropertiesChangedForIndex = propertiesChangedForIndex;
|
||||
_PropertiesChangedForMetadata = propertiesChangedForMetadata;
|
||||
_PropertiesChangedForResize = propertiesChangedForResize;
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_Reverse = reverse;
|
||||
_SaveFaceLandmarkForOutputResolutions = saveFaceLandmarkForOutputResolutions;
|
||||
_SaveFullYearOfRandomFiles = saveFullYearOfRandomFiles;
|
||||
_SaveResizedSubfiles = saveResizedSubfiles;
|
||||
_SaveShortcutsForOutputResolutions = saveShortcutsForOutputResolutions;
|
||||
_SkipSearch = skipSearch;
|
||||
_TestDistanceResults = testDistanceResults;
|
||||
_ValidResolutions = validResolutions;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Set(Property.Models.Configuration configuration) => _PropertyConfiguration = configuration;
|
||||
|
||||
public void Update() => _PropertyConfiguration?.Update();
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.TestsWithFaceRecognitionDotNet.Models.Stateless;
|
||||
|
||||
public abstract class AppSettings
|
||||
{
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings? result;
|
||||
Binder.AppSettings appSettings = configurationRoot.Get<Binder.AppSettings>();
|
||||
string json = JsonSerializer.Serialize(appSettings, new JsonSerializerOptions() { WriteIndented = true });
|
||||
result = JsonSerializer.Deserialize<Models.AppSettings>(json);
|
||||
if (result is null)
|
||||
throw new Exception(json);
|
||||
if (string.IsNullOrEmpty(result.Company))
|
||||
throw new Exception(json);
|
||||
string jsonThis = result.ToString();
|
||||
if (jsonThis != json)
|
||||
{
|
||||
int? check = null;
|
||||
int min = new int[] { json.Length, jsonThis.Length }.Min();
|
||||
for (int i = 0; i < min; i++)
|
||||
{
|
||||
if (json[i] == jsonThis[i])
|
||||
continue;
|
||||
check = i;
|
||||
break;
|
||||
}
|
||||
if (check is null)
|
||||
throw new Exception();
|
||||
string a = json[..check.Value].Split(',')[^1];
|
||||
string b = json[check.Value..].Split(',')[0];
|
||||
throw new Exception($"{a}{b}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Phares.Shared;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace View_by_Distance.TestsWithFaceRecognitionDotNet.Models.Stateless;
|
||||
|
||||
public abstract class Configuration
|
||||
{
|
||||
|
||||
public static Models.Configuration Get(IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, string workingDirectory, Property.Models.Configuration propertyConfiguration)
|
||||
{
|
||||
Models.Configuration? result;
|
||||
string environmentName = IsEnvironment.GetEnvironmentName(isEnvironment);
|
||||
string section = string.Concat(environmentName, ":", nameof(Binder.Configuration));
|
||||
IConfigurationSection configurationSection = configurationRoot.GetSection(section);
|
||||
Binder.Configuration configuration = configurationSection.Get<Binder.Configuration>();
|
||||
string json = JsonSerializer.Serialize(configuration, new JsonSerializerOptions() { WriteIndented = true });
|
||||
result = JsonSerializer.Deserialize<Models.Configuration>(json);
|
||||
if (result is null)
|
||||
throw new Exception(json);
|
||||
string jsonThis = result.ToString();
|
||||
result.Set(propertyConfiguration);
|
||||
result.Update();
|
||||
if (jsonThis != json)
|
||||
{
|
||||
int? check = null;
|
||||
int min = new int[] { json.Length, jsonThis.Length }.Min();
|
||||
for (int i = 0; i < min; i++)
|
||||
{
|
||||
if (json[i] == jsonThis[i])
|
||||
continue;
|
||||
check = i;
|
||||
break;
|
||||
}
|
||||
if (check is null)
|
||||
throw new Exception();
|
||||
string a = json[..check.Value].Split(',')[^1];
|
||||
string b = json[check.Value..].Split(',')[0];
|
||||
throw new Exception($"{a}{b}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user