NullReferenceException

This commit is contained in:
2022-08-13 11:19:08 -07:00
parent 3aeab88384
commit 0392de1920
33 changed files with 1278 additions and 1030 deletions

View File

@ -39,7 +39,7 @@ public class B_Metadata
{
Dictionary<string, List<KeyValuePair<string, string>>> results = new();
if (_Log is null)
throw new ArgumentNullException(nameof(_Log));
throw new NullReferenceException(nameof(_Log));
try
{
object? @object;
@ -78,16 +78,16 @@ public class B_Metadata
return results;
}
public (int, List<KeyValuePair<string, string>>) GetMetadataCollection(List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Property.Models.PropertyHolder propertyHolder)
public (int, List<KeyValuePair<string, string>>) GetMetadataCollection(List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Property.Models.Item item)
{
List<KeyValuePair<string, string>> results = new();
if (propertyHolder.ImageFileHolder is null)
throw new Exception($"{propertyHolder.ImageFileHolder} is null!");
if (item.ImageFileHolder is null)
throw new NullReferenceException(nameof(item.ImageFileHolder));
Dictionary<string, List<KeyValuePair<string, string>>>? dictionary;
string json = string.Empty;
string[] changesFrom = Array.Empty<string>();
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
FileInfo fileInfo = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "{}"), string.Concat(propertyHolder.ImageFileNameWithoutExtension, ".json")));
FileInfo fileInfo = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "{}"), string.Concat(item.ImageFileHolder.NameWithoutExtension, ".json")));
if (!fileInfo.Exists)
{
if (fileInfo.Directory?.Parent is null)
@ -135,7 +135,7 @@ public class B_Metadata
}
if (dictionary is null || !dictionary.Any())
{
dictionary = GetMetadataCollection(propertyHolder.ImageFileHolder.FullName);
dictionary = GetMetadataCollection(item.ImageFileHolder.FullName);
json = JsonSerializer.Serialize(dictionary, _WriteIndentedJsonSerializerOptions);
bool updateDateWhenMatches = dateTimes.Any() && fileInfo.Exists && dateTimes.Max() > fileInfo.LastWriteTime;
DateTime? dateTime = !updateDateWhenMatches ? null : dateTimes.Max();