CSharpMethodLine
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
using ShellProgressBar;
|
||||
using ShellProgressBar;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Property.Models.Stateless;
|
||||
@ -176,6 +176,21 @@ public class A_Property
|
||||
return result;
|
||||
}
|
||||
|
||||
public void SetAngleBracketCollection(string aResultsFullGroupDirectory, string sourceDirectory, bool anyNullOrNoIsUniqueFileName = true)
|
||||
{
|
||||
_AngleBracketCollection.Clear();
|
||||
if (!anyNullOrNoIsUniqueFileName)
|
||||
_AngleBracketCollection.AddRange(new[] { Path.Combine(aResultsFullGroupDirectory, "<>") });
|
||||
else
|
||||
_AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
aResultsFullGroupDirectory,
|
||||
contentDescription: string.Empty,
|
||||
singletonDescription: "Properties for each image",
|
||||
collectionDescription: string.Empty,
|
||||
converted: false));
|
||||
}
|
||||
|
||||
private void SavePropertyParallelForWork(Shared.Models.Methods.IMetadata<MetadataExtractor.Directory> metadata, string sourceDirectory, List<Tuple<string, DateTime>> sourceDirectoryFileTuples, List<Tuple<string, DateTime>> sourceDirectoryChanges, Item item)
|
||||
{
|
||||
Shared.Models.Property property;
|
||||
@ -194,6 +209,18 @@ public class A_Property
|
||||
}
|
||||
}
|
||||
|
||||
private void SetAngleBracketCollection(string sourceDirectory, bool anyNullOrNoIsUniqueFileName)
|
||||
{
|
||||
_AngleBracketCollection.Clear();
|
||||
string aResultsFullGroupDirectory = IResult.GetResultsFullGroupDirectory(_PropertyConfiguration,
|
||||
nameof(A_Property),
|
||||
string.Empty,
|
||||
includeResizeGroup: false,
|
||||
includeModel: false,
|
||||
includePredictorModel: false);
|
||||
SetAngleBracketCollection(aResultsFullGroupDirectory, sourceDirectory, anyNullOrNoIsUniqueFileName);
|
||||
}
|
||||
|
||||
private void SavePropertyParallelWork(int maxDegreeOfParallelism, Shared.Models.Methods.IMetadata<MetadataExtractor.Directory> metadata, List<Exception> exceptions, List<Tuple<string, DateTime>> sourceDirectoryChanges, Container container, List<Item> items, string message)
|
||||
{
|
||||
List<Tuple<string, DateTime>> sourceDirectoryFileTuples = new();
|
||||
@ -223,33 +250,6 @@ public class A_Property
|
||||
});
|
||||
}
|
||||
|
||||
public void SetAngleBracketCollection(string aResultsFullGroupDirectory, string sourceDirectory, bool anyNullOrNoIsUniqueFileName = true)
|
||||
{
|
||||
_AngleBracketCollection.Clear();
|
||||
if (!anyNullOrNoIsUniqueFileName)
|
||||
_AngleBracketCollection.AddRange(new[] { Path.Combine(aResultsFullGroupDirectory, "<>") });
|
||||
else
|
||||
_AngleBracketCollection.AddRange(IResult.GetDirectoryInfoCollection(_PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
aResultsFullGroupDirectory,
|
||||
contentDescription: string.Empty,
|
||||
singletonDescription: "Properties for each image",
|
||||
collectionDescription: string.Empty,
|
||||
converted: false));
|
||||
}
|
||||
|
||||
private void SetAngleBracketCollection(string sourceDirectory, bool anyNullOrNoIsUniqueFileName)
|
||||
{
|
||||
_AngleBracketCollection.Clear();
|
||||
string aResultsFullGroupDirectory = IResult.GetResultsFullGroupDirectory(_PropertyConfiguration,
|
||||
nameof(A_Property),
|
||||
string.Empty,
|
||||
includeResizeGroup: false,
|
||||
includeModel: false,
|
||||
includePredictorModel: false);
|
||||
SetAngleBracketCollection(aResultsFullGroupDirectory, sourceDirectory, anyNullOrNoIsUniqueFileName);
|
||||
}
|
||||
|
||||
public void SavePropertyParallelWork(long ticks, Shared.Models.Methods.IMetadata<MetadataExtractor.Directory> metadata, int t, Container[] containers)
|
||||
{
|
||||
if (_Log is null)
|
||||
|
@ -15,83 +15,12 @@ namespace View_by_Distance.Property.Models.Stateless;
|
||||
internal class Property
|
||||
{
|
||||
|
||||
internal static int GetDeterministicHashCode(byte[] value)
|
||||
private static List<DateTime> GetDateTimes(DateTime dateTimeFromName, DateTime?[] dateTimes)
|
||||
{
|
||||
int result;
|
||||
unchecked
|
||||
List<DateTime> results = new() { dateTimeFromName };
|
||||
foreach (DateTime? dateTime in dateTimes)
|
||||
{
|
||||
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)
|
||||
{
|
||||
PropertyItem result = (PropertyItem)constructorInfo.Invoke(null);
|
||||
int length;
|
||||
byte[] bytes;
|
||||
if (type == 2)
|
||||
{
|
||||
bytes = GetBytes(value);
|
||||
length = value.Length + 1;
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
bytes = Encoding.Unicode.GetBytes($"{value}\0");
|
||||
length = bytes.Length;
|
||||
}
|
||||
else
|
||||
throw new NotSupportedException();
|
||||
result.Id = id;
|
||||
result.Len = length;
|
||||
result.Type = type;
|
||||
result.Value = bytes;
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma warning restore CA1416
|
||||
|
||||
internal static byte[] GetBytes(string value)
|
||||
{
|
||||
byte[] results = new byte[value.Length + 1];
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
results[i] = (byte)value[i];
|
||||
results[value.Length] = 0x00;
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static DateTime? GetDateTime(string dateTimeFormat, string? value)
|
||||
{
|
||||
DateTime? result;
|
||||
string alternateFormat = "ddd MMM dd HH:mm:ss yyyy";
|
||||
if (value is not null && DateTime.TryParse(value, out DateTime dateTime))
|
||||
result = dateTime;
|
||||
else if (value is not null && value.Length == dateTimeFormat.Length && DateTime.TryParseExact(value, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
|
||||
result = dateTime;
|
||||
else if (value is not null && value.Length == alternateFormat.Length && DateTime.TryParseExact(value, alternateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
|
||||
result = dateTime;
|
||||
else
|
||||
result = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<DateTime> GetDateTimes(DateTime?[] metadataDateTimes)
|
||||
{
|
||||
List<DateTime> results = new();
|
||||
foreach (DateTime? dateTime in metadataDateTimes)
|
||||
{
|
||||
if (dateTime is null || results.Contains(dateTime.Value))
|
||||
if (dateTime is null)
|
||||
continue;
|
||||
results.Add(dateTime.Value);
|
||||
}
|
||||
@ -135,20 +64,15 @@ internal class Property
|
||||
return results;
|
||||
}
|
||||
|
||||
private static List<DateTime> GetDateTimes(DateTime dateTimeFromName, DateTime?[] dateTimes)
|
||||
internal static byte[] GetBytes(string value)
|
||||
{
|
||||
List<DateTime> results = new() { dateTimeFromName };
|
||||
foreach (DateTime? dateTime in dateTimes)
|
||||
{
|
||||
if (dateTime is null)
|
||||
continue;
|
||||
results.Add(dateTime.Value);
|
||||
}
|
||||
byte[] results = new byte[value.Length + 1];
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
results[i] = (byte)value[i];
|
||||
results[value.Length] = 0x00;
|
||||
return results;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1416
|
||||
|
||||
internal static DateTime? GetDateTimeFromName(FileHolder fileHolder)
|
||||
{
|
||||
DateTime? result = null;
|
||||
@ -200,6 +124,82 @@ internal class Property
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<DateTime> GetDateTimes(DateTime?[] metadataDateTimes)
|
||||
{
|
||||
List<DateTime> results = new();
|
||||
foreach (DateTime? dateTime in metadataDateTimes)
|
||||
{
|
||||
if (dateTime is null || results.Contains(dateTime.Value))
|
||||
continue;
|
||||
results.Add(dateTime.Value);
|
||||
}
|
||||
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)
|
||||
{
|
||||
PropertyItem result = (PropertyItem)constructorInfo.Invoke(null);
|
||||
int length;
|
||||
byte[] bytes;
|
||||
if (type == 2)
|
||||
{
|
||||
bytes = GetBytes(value);
|
||||
length = value.Length + 1;
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
bytes = Encoding.Unicode.GetBytes($"{value}\0");
|
||||
length = bytes.Length;
|
||||
}
|
||||
else
|
||||
throw new NotSupportedException();
|
||||
result.Id = id;
|
||||
result.Len = length;
|
||||
result.Type = type;
|
||||
result.Value = bytes;
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma warning restore CA1416
|
||||
|
||||
internal static DateTime? GetDateTime(string dateTimeFormat, string? value)
|
||||
{
|
||||
DateTime? result;
|
||||
string alternateFormat = "ddd MMM dd HH:mm:ss yyyy";
|
||||
if (value is not null && DateTime.TryParse(value, out DateTime dateTime))
|
||||
result = dateTime;
|
||||
else if (value is not null && value.Length == dateTimeFormat.Length && DateTime.TryParseExact(value, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
|
||||
result = dateTime;
|
||||
else if (value is not null && value.Length == alternateFormat.Length && DateTime.TryParseExact(value, alternateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
|
||||
result = dateTime;
|
||||
else
|
||||
result = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1416
|
||||
|
||||
internal static (string?, DateTime[], Shared.Models.Property) GetProperty(bool populateId, IMetadata<MetadataExtractor.Directory>? metadata, FileHolder fileHolder, Shared.Models.Property? property, bool isIgnoreExtension, bool isValidImageFormatExtension, int? id, ASCIIEncoding asciiEncoding)
|
||||
{
|
||||
Shared.Models.Property result;
|
||||
|
@ -5,16 +5,10 @@ namespace View_by_Distance.Property.Models.Stateless;
|
||||
internal class Result
|
||||
{
|
||||
|
||||
internal static string GetRelativePath(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string path)
|
||||
internal static string GetResultsDateGroupDirectory(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string description, string jsonGroup)
|
||||
{
|
||||
string result = Shared.Models.Stateless.Methods.IPath.GetRelativePath(path, propertyConfiguration.RootDirectory.Length);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetResultsGroupDirectory(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string description, bool create)
|
||||
{
|
||||
string result = Path.Combine($"{propertyConfiguration.RootDirectory}-Results", description.Replace('_', ')'));
|
||||
if (create && !Directory.Exists(result))
|
||||
string result = Path.Combine(GetResultsDateGroupDirectory(propertyConfiguration, description), jsonGroup);
|
||||
if (!Directory.Exists(result))
|
||||
_ = Directory.CreateDirectory(result);
|
||||
return result;
|
||||
}
|
||||
@ -27,40 +21,9 @@ internal class Result
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetResultsDateGroupDirectory(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string description, string jsonGroup)
|
||||
internal static string GetRelativePath(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string path)
|
||||
{
|
||||
string result = Path.Combine(GetResultsDateGroupDirectory(propertyConfiguration, description), jsonGroup);
|
||||
if (!Directory.Exists(result))
|
||||
_ = Directory.CreateDirectory(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string GetResultsFullGroupDirectory(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel)
|
||||
{
|
||||
string result = GetResultsDateGroupDirectory(propertyConfiguration, description);
|
||||
if (includeResizeGroup)
|
||||
result = Path.Combine(result, outputResolution);
|
||||
if (includeModel && includePredictorModel)
|
||||
{
|
||||
string modelName;
|
||||
string predictorModelName;
|
||||
if (propertyConfiguration.ModelName is null)
|
||||
modelName = Model.Hog.ToString();
|
||||
else
|
||||
modelName = propertyConfiguration.ModelName;
|
||||
if (propertyConfiguration.PredictorModelName is null)
|
||||
predictorModelName = PredictorModel.Large.ToString();
|
||||
else
|
||||
predictorModelName = propertyConfiguration.PredictorModelName;
|
||||
string dateGroupDirectory = string.Concat(outputResolution.Replace(" ", string.Empty), "-", modelName, "-", predictorModelName, "-", propertyConfiguration.NumberOfJitters, "-", propertyConfiguration.NumberOfTimesToUpsample);
|
||||
result = Path.Combine(result, dateGroupDirectory);
|
||||
}
|
||||
else if (includeModel)
|
||||
throw new Exception();
|
||||
else if (includePredictorModel)
|
||||
throw new Exception();
|
||||
if (!Directory.Exists(result))
|
||||
_ = Directory.CreateDirectory(result);
|
||||
string result = Shared.Models.Stateless.Methods.IPath.GetRelativePath(path, propertyConfiguration.RootDirectory.Length);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -111,6 +74,35 @@ internal class Result
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
}
|
||||
|
||||
internal static string GetResultsFullGroupDirectory(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel)
|
||||
{
|
||||
string result = GetResultsDateGroupDirectory(propertyConfiguration, description);
|
||||
if (includeResizeGroup)
|
||||
result = Path.Combine(result, outputResolution);
|
||||
if (includeModel && includePredictorModel)
|
||||
{
|
||||
string modelName;
|
||||
string predictorModelName;
|
||||
if (propertyConfiguration.ModelName is null)
|
||||
modelName = Model.Hog.ToString();
|
||||
else
|
||||
modelName = propertyConfiguration.ModelName;
|
||||
if (propertyConfiguration.PredictorModelName is null)
|
||||
predictorModelName = PredictorModel.Large.ToString();
|
||||
else
|
||||
predictorModelName = propertyConfiguration.PredictorModelName;
|
||||
string dateGroupDirectory = string.Concat(outputResolution.Replace(" ", string.Empty), "-", modelName, "-", predictorModelName, "-", propertyConfiguration.NumberOfJitters, "-", propertyConfiguration.NumberOfTimesToUpsample);
|
||||
result = Path.Combine(result, dateGroupDirectory);
|
||||
}
|
||||
else if (includeModel)
|
||||
throw new Exception();
|
||||
else if (includePredictorModel)
|
||||
throw new Exception();
|
||||
if (!Directory.Exists(result))
|
||||
_ = Directory.CreateDirectory(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static List<string> GetDirectoryInfoCollection(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string sourceDirectory, string dateGroupDirectory, string contentDescription, string singletonDescription, string collectionDescription, bool converted)
|
||||
{
|
||||
List<string> results = new();
|
||||
@ -126,6 +118,14 @@ internal class Result
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static string GetResultsGroupDirectory(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string description, bool create)
|
||||
{
|
||||
string result = Path.Combine($"{propertyConfiguration.RootDirectory}-Results", description.Replace('_', ')'));
|
||||
if (create && !Directory.Exists(result))
|
||||
_ = Directory.CreateDirectory(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static List<string> GetDirectoryInfoCollection(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, string sourceDirectory, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel, string contentDescription, string singletonDescription, string collectionDescription)
|
||||
{
|
||||
List<string> results;
|
||||
|
Reference in New Issue
Block a user