moved-container-to-new-project-to-prepare-to-remove-property-file added-logic-to-rename-to-3-and-7-like-should-ignore-for-missing-date-time-original
70 lines
2.4 KiB
C#
70 lines
2.4 KiB
C#
using System.Globalization;
|
|
using View_by_Distance.Shared.Models;
|
|
|
|
namespace View_by_Distance.Metadata.Models.Stateless.Methods;
|
|
|
|
internal static class Base
|
|
{
|
|
|
|
internal static string? GetMaker(ExifDirectoryBase[]? exifBaseDirectories)
|
|
{
|
|
string? result = null;
|
|
if (exifBaseDirectories is not null)
|
|
{
|
|
string value;
|
|
foreach (ExifDirectoryBase exifDirectoryBase in exifBaseDirectories)
|
|
{
|
|
value = exifDirectoryBase?.Make is null ? string.Empty : exifDirectoryBase.Make.ToString().Trim();
|
|
if (string.IsNullOrEmpty(value))
|
|
result = null;
|
|
else
|
|
{
|
|
result = $"{value[0].ToString().ToUpper()}{value[1..].ToLower()}";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
internal static string? GetModel(ExifDirectoryBase[]? exifBaseDirectories)
|
|
{
|
|
string? result = null;
|
|
if (exifBaseDirectories is not null)
|
|
{
|
|
string value;
|
|
foreach (ExifDirectoryBase exifDirectoryBase in exifBaseDirectories)
|
|
{
|
|
value = exifDirectoryBase?.Model is null ? string.Empty : exifDirectoryBase.Model.ToString().Trim();
|
|
if (string.IsNullOrEmpty(value))
|
|
result = null;
|
|
else
|
|
{
|
|
result = value;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
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
|
|
|
|
} |