83 lines
3.3 KiB
C#
83 lines
3.3 KiB
C#
using System.Text.Json.Serialization;
|
|
|
|
namespace View_by_Distance.Property.Models;
|
|
|
|
public class PropertyHolder
|
|
{
|
|
|
|
protected readonly bool? _Abandoned;
|
|
protected readonly bool? _Changed;
|
|
protected FileInfo? _ImageFileInfo;
|
|
protected readonly int _G;
|
|
protected DateTime? _MinimumDateTime;
|
|
protected bool? _Moved;
|
|
protected readonly bool? _NoJson;
|
|
protected A_Property? _Property;
|
|
protected readonly int _R;
|
|
protected readonly string _RelativePath;
|
|
protected FileInfo? _ResizedFileInfo;
|
|
protected readonly string _SourceDirectory;
|
|
protected readonly string _SourceDirectoryFile;
|
|
protected bool? _ValidImageFormatExtension;
|
|
protected bool? _WrongYear;
|
|
public bool? Abandoned => _Abandoned;
|
|
public bool? Changed => _Changed;
|
|
public FileInfo? ImageFileInfo => _ImageFileInfo;
|
|
public int G => _G;
|
|
public DateTime? MinimumDateTime => _MinimumDateTime;
|
|
public bool? Moved => _Moved;
|
|
public bool? NoJson => _NoJson;
|
|
public A_Property? Property => _Property;
|
|
public int R => _R;
|
|
public string RelativePath => _RelativePath;
|
|
public FileInfo? ResizedFileInfo => _ResizedFileInfo;
|
|
public string SourceDirectory => _SourceDirectory;
|
|
public string SourceDirectoryFile => _SourceDirectoryFile;
|
|
public bool? ValidImageFormatExtension => _ValidImageFormatExtension;
|
|
public bool? WrongYear => _WrongYear;
|
|
|
|
public PropertyHolder()
|
|
{
|
|
_G = -1;
|
|
_SourceDirectory = string.Empty;
|
|
_SourceDirectoryFile = string.Empty;
|
|
_RelativePath = string.Empty;
|
|
_R = -1;
|
|
}
|
|
|
|
[JsonConstructor]
|
|
public PropertyHolder(int g, string sourceDirectory, string sourceDirectoryFile, string relativePath, int r, FileInfo? imageFileInfo, A_Property? property, bool? abandoned, bool? changed, bool? moved, bool? validImageFormatExtension, bool? wrongYear)
|
|
{
|
|
_Abandoned = abandoned;
|
|
_Changed = changed;
|
|
_ImageFileInfo = imageFileInfo;
|
|
_G = g;
|
|
_Moved = moved;
|
|
_NoJson = abandoned is null;
|
|
_Property = property;
|
|
_R = r;
|
|
_RelativePath = relativePath;
|
|
_SourceDirectory = sourceDirectory;
|
|
_SourceDirectoryFile = sourceDirectoryFile;
|
|
_ValidImageFormatExtension = validImageFormatExtension;
|
|
_WrongYear = wrongYear;
|
|
_MinimumDateTime = Stateless.A_Property.GetMinimumDateTime(property);
|
|
if (imageFileInfo is not null && imageFileInfo.Extension is ".json")
|
|
throw new ArgumentException("Can not be a *.json file!");
|
|
if (!sourceDirectoryFile.EndsWith(".json") && !sourceDirectoryFile.EndsWith(".old"))
|
|
throw new ArgumentException("Must be a *.json or *.old file!");
|
|
}
|
|
|
|
internal void SetValidImageFormatExtension(bool isValidImageFormatExtension) => _ValidImageFormatExtension = isValidImageFormatExtension;
|
|
|
|
internal void SetWrongYear(bool wrongYear) => _WrongYear = wrongYear;
|
|
|
|
internal void SetMoved(bool moved) => _Moved = moved;
|
|
|
|
public void SetResizedFileInfo(FileInfo fileInfo) => _ResizedFileInfo = fileInfo;
|
|
|
|
internal void Update(A_Property property) => _Property = property;
|
|
|
|
public bool Any() => (_Abandoned.HasValue && _Abandoned.Value) || (_Changed.HasValue && _Changed.Value) || (_Moved.HasValue && _Moved.Value) || (_NoJson.HasValue && _NoJson.Value);
|
|
|
|
} |