.config
.vscode
BlurHash
BlurHash.Core
BlurHash.System.Drawing.Common
Compare
Copy-Distinct
Date-Group
Delete-By-Distinct
Delete-By-Relative
Distance
Drag-Drop-Explorer
Drag-Drop-Move
Drag-Drop-Search
Drag-Drop-Set-Property-Item
Duplicate-Search
Face
FaceParts
FaceRecognitionDotNet
Instance
Map
Metadata
Metadata-Query
Mirror-Length
Move-By-Id
Offset-Date-Time-Original
PhotoPrism
PrepareForOld
.vscode
Models
Binder
SaveTabSeparatedValues
Stateless
Configuration.cs
AppSettings.cs
Configuration.cs
PrepareForOld.csproj
Program.cs
appsettings.Development.json
Property
Property-Compare
Rename
Resize
Set-Created-Date
Shared
Tests
TestsWithFaceRecognitionDotNet
ThumbHash
.editorconfig
.gitattributes
.gitignore
.prettierignore
.txt
View-by-Distance-MKLink-Console.sln
package-lock.json
package.json
42 lines
1.7 KiB
C#
42 lines
1.7 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Phares.Shared;
|
|
using System.Text.Json;
|
|
|
|
namespace View_by_Distance.PrepareForOld.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();
|
|
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;
|
|
}
|
|
|
|
} |