FilePath ready to test

This commit is contained in:
2023-12-24 11:29:36 -07:00
parent af491371a3
commit 7007a9df2e
60 changed files with 960 additions and 857 deletions

View File

@ -1,4 +1,5 @@
using ShellProgressBar;
using System.Collections.ObjectModel;
using System.Text;
using System.Text.Json;
using View_by_Distance.Property.Models.Stateless;
@ -21,7 +22,7 @@ public class A_Property
private readonly Configuration _Configuration;
private readonly List<string> _AngleBracketCollection;
private readonly IPropertyConfiguration _PropertyConfiguration;
private readonly IReadOnlyDictionary<string, string[]> _FileGroups;
private readonly ReadOnlyDictionary<string, string[]> _FileGroups;
public A_Property(int maxDegreeOfParallelism, Configuration propertyConfiguration, string outputExtension, bool reverse, string aResultsFullGroupDirectory)
{
@ -56,7 +57,7 @@ public class A_Property
fileInfo = new(Path.Combine(angleBracket.Replace("<>", _PropertyConfiguration.ResultSingleton), $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
else
{
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration.ResultAllInOneSubdirectoryLength, item.ImageFileHolder.Name);
(_, int directoryIndex) = Shared.Models.Stateless.Methods.IPath.GetDirectoryNameAndIndex(_PropertyConfiguration, item.FilePath);
fileInfo = new(Path.Combine(_FileGroups[_PropertyConfiguration.ResultSingleton][directoryIndex], $"{item.ImageFileHolder.NameWithoutExtension}{item.ImageFileHolder.ExtensionLowered}.json"));
}
List<DateTime> dateTimes = (from l in sourceDirectoryFileTuples where l is not null && changesFrom.Contains(l.Item1) select l.Item2).ToList();
@ -133,7 +134,7 @@ public class A_Property
}
if (result is null)
{
id ??= item.ImageFileHolder.Id;
id ??= item.FilePath.Id;
(_, _, result) = Stateless.Property.GetProperty(populateId, metadata, item.ImageFileHolder, result, isIgnoreExtension, item.IsValidImageFormatExtension, id, _ASCIIEncoding);
json = JsonSerializer.Serialize(result, PropertyGenerationContext.Default.Property);
if (populateId && Shared.Models.Stateless.Methods.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches: true, compareBeforeWrite: true))

View File

@ -12,6 +12,7 @@ public class Configuration
public bool? ForcePropertyLastWriteTimeToCreationTime { get; set; }
public string[]? IgnoreExtensions { get; set; }
public string[]? IgnoreRulesKeyWords { get; set; }
public int? IntMinValueLength { get; set; }
public int? MaxImagesInDirectoryForTopLevelFirstPass { get; set; }
public string? ModelName { init; get; }
public int? NumberOfJitters { init; get; }
@ -47,6 +48,7 @@ public class Configuration
if (configuration.ForcePropertyLastWriteTimeToCreationTime is null) throw new NullReferenceException(nameof(configuration.ForcePropertyLastWriteTimeToCreationTime));
if (configuration.IgnoreExtensions is null) throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
if (configuration.IgnoreRulesKeyWords is null) throw new NullReferenceException(nameof(configuration.IgnoreRulesKeyWords));
if (configuration.IntMinValueLength is null) throw new NullReferenceException(nameof(configuration.IntMinValueLength));
if (configuration.MaxImagesInDirectoryForTopLevelFirstPass is null) throw new NullReferenceException(nameof(configuration.MaxImagesInDirectoryForTopLevelFirstPass));
// if (configuration.ModelName is null) throw new NullReferenceException(nameof(configuration.ModelName));
// if (configuration.NumberOfJitters is null) throw new NullReferenceException(nameof(configuration.NumberOfJitters));
@ -71,6 +73,7 @@ public class Configuration
configuration.ForcePropertyLastWriteTimeToCreationTime.Value,
configuration.IgnoreExtensions,
configuration.IgnoreRulesKeyWords,
configuration.IntMinValueLength.Value,
configuration.MaxImagesInDirectoryForTopLevelFirstPass.Value,
configuration.ModelName,
configuration.NumberOfJitters,

View File

@ -15,6 +15,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
public bool ForcePropertyLastWriteTimeToCreationTime { init; get; }
public string[] IgnoreExtensions { init; get; }
public string[] IgnoreRulesKeyWords { init; get; }
public int IntMinValueLength { init; get; }
public int MaxImagesInDirectoryForTopLevelFirstPass { init; get; }
public string? ModelName { init; get; }
public int? NumberOfJitters { init; get; }
@ -39,6 +40,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
bool forcePropertyLastWriteTimeToCreationTime,
string[] ignoreExtensions,
string[] ignoreRulesKeyWords,
int intMinValueLength,
int maxImagesInDirectoryForTopLevelFirstPass,
string? modelName,
int? numberOfJitters,
@ -64,6 +66,7 @@ public class Configuration : Shared.Models.Properties.IPropertyConfiguration
ForcePropertyLastWriteTimeToCreationTime = forcePropertyLastWriteTimeToCreationTime;
IgnoreExtensions = ignoreExtensions;
IgnoreRulesKeyWords = ignoreRulesKeyWords;
IntMinValueLength = intMinValueLength;
MaxImagesInDirectoryForTopLevelFirstPass = maxImagesInDirectoryForTopLevelFirstPass;
ModelName = modelName;
NumberOfJitters = numberOfJitters;

View File

@ -13,11 +13,6 @@ public interface IProperty
static string DateTimeFormat() =>
"yyyy:MM:dd HH:mm:ss";
int TestStatic_GetDeterministicHashCode(byte[] value) =>
GetDeterministicHashCode(value);
static int GetDeterministicHashCode(byte[] value) =>
Property.GetDeterministicHashCode(value);
byte[] TestStatic_GetBytes(string value) =>
GetBytes(value);
static byte[] GetBytes(string value) =>

View File

@ -139,25 +139,6 @@ internal partial class Property
return results;
}
internal static int GetDeterministicHashCode(byte[] value)
{
int result;
unchecked
{
int hash1 = (5381 << 16) + 5381;
int hash2 = hash1;
for (int i = 0; i < value.Length; i += 2)
{
hash1 = ((hash1 << 5) + hash1) ^ value[i];
if (i == value.Length - 1)
break;
hash2 = ((hash2 << 5) + hash2) ^ value[i + 1];
}
result = hash1 + (hash2 * 1566083941);
}
return result;
}
#pragma warning disable CA1416
internal static PropertyItem GetPropertyItem(ConstructorInfo constructorInfo, int id, short type, string value)
@ -260,7 +241,7 @@ internal partial class Property
bytes = new byte[length];
Marshal.Copy(intPtr, bytes, 0, length);
bitmap.UnlockBits(bitmapData);
id ??= GetDeterministicHashCode(bytes);
id ??= Shared.Models.Stateless.Methods.IId.GetDeterministicHashCode(bytes);
}
dateTimeFormat = IProperty.DateTimeFormat();
if (image.PropertyIdList.Contains((int)IExif.Tags.DateTime))