61 lines
4.3 KiB
C#
61 lines
4.3 KiB
C#
namespace View_by_Distance.Shared.Models.Stateless;
|
|
|
|
public interface IId
|
|
{
|
|
|
|
const int DeterministicHashCode = 9876543;
|
|
|
|
static bool IsOffsetDeterministicHashCode(MetadataSettings metadataSettings) =>
|
|
metadataSettings.Offset == DeterministicHashCode;
|
|
|
|
string TestStatic_GetIntelligentId(ResultSettings resultSettings, MetadataSettings metadataSettings, long id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal) =>
|
|
GetIntelligentId(resultSettings, metadataSettings, id, hasIgnoreKeyword, hasDateTimeOriginal);
|
|
static string GetIntelligentId(ResultSettings resultSettings, MetadataSettings metadataSettings, long id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal) =>
|
|
Id.GetIntelligentId(resultSettings, metadataSettings, id, hasIgnoreKeyword, hasDateTimeOriginal);
|
|
|
|
int TestStatic_GetId(ResultSettings resultSettings, MetadataSettings metadataSettings, string intelligentId) =>
|
|
GetId(resultSettings, metadataSettings, intelligentId);
|
|
static int GetId(ResultSettings resultSettings, MetadataSettings metadataSettings, string intelligentId) =>
|
|
Id.GetId(resultSettings, metadataSettings, intelligentId);
|
|
|
|
string TestStatic_GetPaddedId(ResultSettings resultSettings, MetadataSettings metadataSettings, int id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) =>
|
|
GetPaddedId(resultSettings, metadataSettings, id, hasIgnoreKeyword, hasDateTimeOriginal, index);
|
|
static string GetPaddedId(ResultSettings resultSettings, MetadataSettings metadataSettings, int id, bool? hasIgnoreKeyword, bool? hasDateTimeOriginal, int? index) =>
|
|
Id.GetPaddedId(resultSettings, metadataSettings, id, hasIgnoreKeyword, hasDateTimeOriginal, index);
|
|
|
|
string TestStatic_GetIgnoreFullPath(FilePath filePath, FileHolder fileHolder) =>
|
|
GetIgnoreFullPath(filePath, fileHolder);
|
|
static string GetIgnoreFullPath(FilePath filePath, FileHolder fileHolder) =>
|
|
fileHolder.DirectoryFullPath is null ?
|
|
throw new NotSupportedException() :
|
|
filePath.Id > -1 ?
|
|
fileHolder.NameWithoutExtension[^1] == '9' ?
|
|
Path.Combine(fileHolder.DirectoryFullPath, $"{fileHolder.NameWithoutExtension[..^1]}8{fileHolder.ExtensionLowered}") :
|
|
throw new NotSupportedException("High") :
|
|
fileHolder.NameWithoutExtension[^1] == '1' ?
|
|
Path.Combine(fileHolder.DirectoryFullPath, $"{fileHolder.NameWithoutExtension[..^1]}2{fileHolder.ExtensionLowered}") :
|
|
throw new NotSupportedException("Low");
|
|
|
|
bool TestStatic_NameWithoutExtensionIsIntelligentIdFormat(MetadataSettings metadataSettings, string fileNameFirstSegment) =>
|
|
NameWithoutExtensionIsIntelligentIdFormat(metadataSettings, fileNameFirstSegment);
|
|
static bool NameWithoutExtensionIsIntelligentIdFormat(MetadataSettings metadataSettings, string fileNameFirstSegment) =>
|
|
fileNameFirstSegment.Length - 1 == metadataSettings.IntMinValueLength && fileNameFirstSegment[^1] is '1' or '2' or '8' or '9' && fileNameFirstSegment.All(char.IsNumber);
|
|
|
|
bool TestStatic_NameWithoutExtensionIsPaddedIntelligentIdFormat(MetadataSettings metadataSettings, int sortOrderOnlyLengthIndex, string fileNameFirstSegment) =>
|
|
NameWithoutExtensionIsPaddedIntelligentIdFormat(metadataSettings, sortOrderOnlyLengthIndex, fileNameFirstSegment);
|
|
static bool NameWithoutExtensionIsPaddedIntelligentIdFormat(MetadataSettings metadataSettings, int sortOrderOnlyLengthIndex, string fileNameFirstSegment) =>
|
|
fileNameFirstSegment.Length == metadataSettings.IntMinValueLength + sortOrderOnlyLengthIndex + 1
|
|
&& fileNameFirstSegment[^1] is '1' or '2' or '8' or '9'
|
|
&& fileNameFirstSegment.All(char.IsNumber);
|
|
|
|
bool TestStatic_NameWithoutExtensionIsIdFormat(MetadataSettings metadataSettings, FileHolder fileHolder) =>
|
|
NameWithoutExtensionIsIdFormat(metadataSettings, fileHolder);
|
|
static bool NameWithoutExtensionIsIdFormat(MetadataSettings metadataSettings, FileHolder fileHolder) =>
|
|
Id.NameWithoutExtensionIsIdFormat(metadataSettings, fileHolder.NameWithoutExtension.Split('.')[0]);
|
|
|
|
int TestStatic_GetDeterministicHashCode(byte[] value) =>
|
|
GetDeterministicHashCode(value);
|
|
static int GetDeterministicHashCode(byte[] value) =>
|
|
Id.GetDeterministicHashCode(value);
|
|
|
|
} |