Change to only need the one json file and changed AppSettings to not need a binder file Editorconfig for no new line before open braces Nuget package bumps Database lowest-version-history
40 lines
1.6 KiB
C#
40 lines
1.6 KiB
C#
using ImmichToSlideshow.Domain;
|
|
using System.Collections.ObjectModel;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace ImmichToSlideshow.Models;
|
|
|
|
public sealed record Identifier(string[] DirectoryNames,
|
|
string Extension,
|
|
bool? HasDateTimeOriginal,
|
|
int Id,
|
|
long Length,
|
|
string PaddedId,
|
|
long Ticks) {
|
|
|
|
public override string ToString() {
|
|
string result = JsonSerializer.Serialize(this, IdentifierSourceGenerationContext.Default.Identifier);
|
|
return result;
|
|
}
|
|
|
|
internal static string GetDeviceAssetIds(ReadOnlyCollection<Identifier> identifiers) =>
|
|
$"'{string.Join($"',{Environment.NewLine}'", (from l in identifiers select GetDeviceAssetId(l)).ToArray())}'";
|
|
|
|
internal static string GetDeviceAssetIds(ReadOnlyCollection<ImageTag> imageTags) =>
|
|
$"'{string.Join($"',{Environment.NewLine}'", (from l in imageTags select l.Name).ToArray())}'";
|
|
|
|
internal static string GetDeviceAssetId(Identifier identifier) =>
|
|
$"{identifier.PaddedId}{identifier.Extension}";
|
|
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Identifier))]
|
|
public partial class IdentifierSourceGenerationContext : JsonSerializerContext {
|
|
}
|
|
|
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
|
[JsonSerializable(typeof(Identifier[]))]
|
|
public partial class IdentifierCollectionSourceGenerationContext : JsonSerializerContext {
|
|
} |