From 6c92bf5737db042f3068851ab56927305fd523e5 Mon Sep 17 00:00:00 2001 From: KatterMaw Date: Sun, 8 Oct 2023 06:41:05 +0500 Subject: [PATCH] Expose Ids to domain; Use FlakeId (long in database) as part of preparations for future web functionality; --- SightKeeper.Data/AppDbContext.cs | 3 ++- .../Configuration/AssetConfiguration.cs | 3 ++- .../Configuration/DataSetConfiguration.cs | 3 ++- .../Configuration/DetectorItemConfiguration.cs | 3 ++- SightKeeper.Data/Configuration/GameConfiguration.cs | 3 ++- .../Configuration/ImageConfiguration.cs | 3 ++- .../Configuration/ItemClassConfiguration.cs | 3 ++- .../Configuration/ProfileConfiguration.cs | 3 ++- .../Configuration/ProfileItemClassConfiguration.cs | 3 ++- .../Configuration/ScreenshotConfiguration.cs | 3 ++- .../ScreenshotsLibraryConfiguration.cs | 3 ++- .../Configuration/WeightsConfiguration.cs | 3 ++- .../Configuration/WeightsLibraryConfiguration.cs | 3 ++- SightKeeper.Data/Extensions.cs | 13 ++++++++----- SightKeeper.Data/FlakeIdGenerator.cs | 11 +++++++++++ SightKeeper.Data/SightKeeper.Data.csproj | 1 + SightKeeper.Domain.Model/Common/Asset.cs | 4 +++- SightKeeper.Domain.Model/Common/Game.cs | 5 ++++- SightKeeper.Domain.Model/Common/Image.cs | 5 ++++- SightKeeper.Domain.Model/Common/ItemClass.cs | 2 ++ SightKeeper.Domain.Model/DataSet/DataSet.cs | 2 ++ SightKeeper.Domain.Model/DataSet/Weights/Weights.cs | 4 +++- .../DataSet/Weights/WeightsData.cs | 5 ++++- .../DataSet/Weights/WeightsLibrary.cs | 2 ++ SightKeeper.Domain.Model/Detector/DetectorItem.cs | 4 +++- SightKeeper.Domain.Model/Profile/Profile.cs | 2 ++ .../Profile/ProfileItemClass.cs | 4 +++- SightKeeper.Domain.Model/Screenshots/Screenshot.cs | 4 +++- .../Screenshots/ScreenshotsLibrary.cs | 2 ++ .../SightKeeper.Domain.Model.csproj | 1 + .../ProfilesObservableRepository.cs | 8 +++++++- 31 files changed, 91 insertions(+), 27 deletions(-) create mode 100644 SightKeeper.Data/FlakeIdGenerator.cs diff --git a/SightKeeper.Data/AppDbContext.cs b/SightKeeper.Data/AppDbContext.cs index fcd22efd..3835073e 100644 --- a/SightKeeper.Data/AppDbContext.cs +++ b/SightKeeper.Data/AppDbContext.cs @@ -76,7 +76,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.ApplyConfiguration(new ProfileItemClassConfiguration()); modelBuilder.ApplyConfiguration(new WeightsConfiguration()); modelBuilder.Entity().Navigation(asset => asset.Screenshot).AutoInclude(); - modelBuilder.Entity().HasShadowKey(); + modelBuilder.Entity().HasKey(weightsData => weightsData.Id); + modelBuilder.Entity().HasFlakeId(weightsData => weightsData.Id); modelBuilder.Entity().ToTable("PTData"); modelBuilder.Entity().ToTable("ONNXData"); } diff --git a/SightKeeper.Data/Configuration/AssetConfiguration.cs b/SightKeeper.Data/Configuration/AssetConfiguration.cs index 7a0652e9..da5ca439 100644 --- a/SightKeeper.Data/Configuration/AssetConfiguration.cs +++ b/SightKeeper.Data/Configuration/AssetConfiguration.cs @@ -8,7 +8,8 @@ public sealed class AssetConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { + builder.HasKey(asset => asset.Id); + builder.HasFlakeId(asset => asset.Id); builder.ToTable("Assets"); - builder.HasShadowKey(); } } \ No newline at end of file diff --git a/SightKeeper.Data/Configuration/DataSetConfiguration.cs b/SightKeeper.Data/Configuration/DataSetConfiguration.cs index f36c7703..3d8442de 100644 --- a/SightKeeper.Data/Configuration/DataSetConfiguration.cs +++ b/SightKeeper.Data/Configuration/DataSetConfiguration.cs @@ -8,7 +8,8 @@ public sealed class DataSetConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { - builder.HasShadowKey(); + builder.HasKey(dataSet => dataSet.Id); + builder.HasFlakeId(dataSet => dataSet.Id); builder.HasIndex(dataSet => dataSet.Name).IsUnique(); builder.HasOne(dataSet => dataSet.ScreenshotsLibrary).WithOne(library => library.DataSet).HasPrincipalKey(); builder.HasOne(dataSet => dataSet.WeightsLibrary).WithOne(library => library.DataSet).HasPrincipalKey(); diff --git a/SightKeeper.Data/Configuration/DetectorItemConfiguration.cs b/SightKeeper.Data/Configuration/DetectorItemConfiguration.cs index cd62a013..3f590fee 100644 --- a/SightKeeper.Data/Configuration/DetectorItemConfiguration.cs +++ b/SightKeeper.Data/Configuration/DetectorItemConfiguration.cs @@ -8,8 +8,9 @@ public sealed class DetectorItemConfiguration : IEntityTypeConfiguration builder) { + builder.HasKey(item => item.Id); + builder.HasFlakeId(item => item.Id); builder.ToTable("DetectorItems"); - builder.HasShadowKey(); builder.OwnsOne(item => item.Bounding, boundingBuilder => { boundingBuilder.Property(bounding => bounding.Left).HasColumnName("BoundingLeft"); diff --git a/SightKeeper.Data/Configuration/GameConfiguration.cs b/SightKeeper.Data/Configuration/GameConfiguration.cs index c020aff7..61690faf 100644 --- a/SightKeeper.Data/Configuration/GameConfiguration.cs +++ b/SightKeeper.Data/Configuration/GameConfiguration.cs @@ -8,6 +8,7 @@ public sealed class GameConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { - builder.HasShadowKey(); + builder.HasKey(game => game.Id); + builder.HasFlakeId(game => game.Id); } } \ No newline at end of file diff --git a/SightKeeper.Data/Configuration/ImageConfiguration.cs b/SightKeeper.Data/Configuration/ImageConfiguration.cs index 8fe17c9e..b6bdd778 100644 --- a/SightKeeper.Data/Configuration/ImageConfiguration.cs +++ b/SightKeeper.Data/Configuration/ImageConfiguration.cs @@ -8,7 +8,8 @@ public sealed class ImageConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { - builder.HasShadowKey(); + builder.HasKey(image => image.Id); + builder.HasFlakeId(image => image.Id); builder.ToTable("Images"); } } \ No newline at end of file diff --git a/SightKeeper.Data/Configuration/ItemClassConfiguration.cs b/SightKeeper.Data/Configuration/ItemClassConfiguration.cs index a3395686..2f6b5c54 100644 --- a/SightKeeper.Data/Configuration/ItemClassConfiguration.cs +++ b/SightKeeper.Data/Configuration/ItemClassConfiguration.cs @@ -8,7 +8,8 @@ public sealed class ItemClassConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { + builder.HasKey(itemClass => itemClass.Id); + builder.HasFlakeId(itemClass => itemClass.Id); builder.ToTable("ItemClasses"); - builder.HasShadowKey(); } } \ No newline at end of file diff --git a/SightKeeper.Data/Configuration/ProfileConfiguration.cs b/SightKeeper.Data/Configuration/ProfileConfiguration.cs index e079a1f0..6b45914c 100644 --- a/SightKeeper.Data/Configuration/ProfileConfiguration.cs +++ b/SightKeeper.Data/Configuration/ProfileConfiguration.cs @@ -8,7 +8,8 @@ public sealed class ProfileConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { - builder.HasShadowKey(); + builder.HasKey(profile => profile.Id); + builder.HasFlakeId(profile => profile.Id); builder.HasMany(profile => profile.ItemClasses).WithOne().IsRequired(); builder.HasIndex(profile => profile.Name).IsUnique(); builder.Navigation(profile => profile.Weights).AutoInclude(); diff --git a/SightKeeper.Data/Configuration/ProfileItemClassConfiguration.cs b/SightKeeper.Data/Configuration/ProfileItemClassConfiguration.cs index 326615d0..87366929 100644 --- a/SightKeeper.Data/Configuration/ProfileItemClassConfiguration.cs +++ b/SightKeeper.Data/Configuration/ProfileItemClassConfiguration.cs @@ -8,7 +8,8 @@ public sealed class ProfileItemClassConfiguration : IEntityTypeConfiguration builder) { - builder.HasShadowKey(); + builder.HasKey(profileItemClass => profileItemClass.Id); + builder.HasFlakeId(profileItemClass => profileItemClass.Id); builder.ToTable("ProfileItemClasses"); builder.HasIndex("ProfileId", nameof(ProfileItemClass.Index)).IsUnique(); builder.HasIndex("ProfileId", "ItemClassId").IsUnique(); diff --git a/SightKeeper.Data/Configuration/ScreenshotConfiguration.cs b/SightKeeper.Data/Configuration/ScreenshotConfiguration.cs index 56db3943..30fa2c6e 100644 --- a/SightKeeper.Data/Configuration/ScreenshotConfiguration.cs +++ b/SightKeeper.Data/Configuration/ScreenshotConfiguration.cs @@ -8,8 +8,9 @@ public sealed class ScreenshotConfiguration : IEntityTypeConfiguration builder) { + builder.HasKey(screenshot => screenshot.Id); + builder.HasFlakeId(screenshot => screenshot.Id); builder.ToTable("Screenshots"); - builder.HasShadowKey(); builder.HasOne(screenshot => screenshot.Asset).WithOne(asset => asset.Screenshot).HasPrincipalKey(); builder.HasOne(screenshot => screenshot.Image).WithOne().HasPrincipalKey().IsRequired(); builder.Navigation(screenshot => screenshot.Asset).AutoInclude(); diff --git a/SightKeeper.Data/Configuration/ScreenshotsLibraryConfiguration.cs b/SightKeeper.Data/Configuration/ScreenshotsLibraryConfiguration.cs index adeff028..2ced9e77 100644 --- a/SightKeeper.Data/Configuration/ScreenshotsLibraryConfiguration.cs +++ b/SightKeeper.Data/Configuration/ScreenshotsLibraryConfiguration.cs @@ -8,7 +8,8 @@ public sealed class ScreenshotsLibraryConfiguration : IEntityTypeConfiguration builder) { - builder.HasShadowKey(); + builder.HasKey(library => library.Id); + builder.HasFlakeId(library => library.Id); builder.ToTable("ScreenshotsLibraries"); } } \ No newline at end of file diff --git a/SightKeeper.Data/Configuration/WeightsConfiguration.cs b/SightKeeper.Data/Configuration/WeightsConfiguration.cs index 3146b7e4..521cd571 100644 --- a/SightKeeper.Data/Configuration/WeightsConfiguration.cs +++ b/SightKeeper.Data/Configuration/WeightsConfiguration.cs @@ -9,7 +9,8 @@ public sealed class WeightsConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { - builder.HasShadowKey(); + builder.HasKey(weights => weights.Id); + builder.HasFlakeId(weights => weights.Id); builder .HasMany(weights => weights.Assets) .WithMany() diff --git a/SightKeeper.Data/Configuration/WeightsLibraryConfiguration.cs b/SightKeeper.Data/Configuration/WeightsLibraryConfiguration.cs index 3775712f..b2793d0a 100644 --- a/SightKeeper.Data/Configuration/WeightsLibraryConfiguration.cs +++ b/SightKeeper.Data/Configuration/WeightsLibraryConfiguration.cs @@ -8,8 +8,9 @@ public sealed class WeightsLibraryConfiguration : IEntityTypeConfiguration builder) { + builder.HasKey(library => library.Id); + builder.HasFlakeId(library => library.Id); builder.ToTable("WeightsLibraries"); - builder.HasShadowKey(); builder.Navigation(library => library.DataSet).AutoInclude(); builder.Navigation(library => library.Weights).AutoInclude(); } diff --git a/SightKeeper.Data/Extensions.cs b/SightKeeper.Data/Extensions.cs index 581b8dd4..8b177d40 100644 --- a/SightKeeper.Data/Extensions.cs +++ b/SightKeeper.Data/Extensions.cs @@ -1,4 +1,6 @@ -using Microsoft.EntityFrameworkCore.ChangeTracking; +using System.Linq.Expressions; +using FlakeId; +using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace SightKeeper.Data; @@ -6,11 +8,12 @@ namespace SightKeeper.Data; public static class Extensions { private const string IdPropertyName = "Id"; - - public static EntityTypeBuilder HasShadowKey(this EntityTypeBuilder builder) where TEntity : class + + public static EntityTypeBuilder HasFlakeId(this EntityTypeBuilder builder, Expression> propertyExpression) where TEntity : class { - builder.Property(IdPropertyName); - builder.HasKey(IdPropertyName); + builder.Property(propertyExpression) + .HasValueGenerator() + .HasConversion(id => id, number => new Id(number)); return builder; } diff --git a/SightKeeper.Data/FlakeIdGenerator.cs b/SightKeeper.Data/FlakeIdGenerator.cs new file mode 100644 index 00000000..a63737fe --- /dev/null +++ b/SightKeeper.Data/FlakeIdGenerator.cs @@ -0,0 +1,11 @@ +using FlakeId; +using Microsoft.EntityFrameworkCore.ChangeTracking; +using Microsoft.EntityFrameworkCore.ValueGeneration; + +namespace SightKeeper.Data; + +public sealed class FlakeIdGenerator : ValueGenerator +{ + public override bool GeneratesTemporaryValues => false; + public override Id Next(EntityEntry entry) => Id.Create(); +} \ No newline at end of file diff --git a/SightKeeper.Data/SightKeeper.Data.csproj b/SightKeeper.Data/SightKeeper.Data.csproj index 117c5645..02dfb4f3 100644 --- a/SightKeeper.Data/SightKeeper.Data.csproj +++ b/SightKeeper.Data/SightKeeper.Data.csproj @@ -8,6 +8,7 @@ + diff --git a/SightKeeper.Domain.Model/Common/Asset.cs b/SightKeeper.Domain.Model/Common/Asset.cs index 7d5fb79b..67f41919 100644 --- a/SightKeeper.Domain.Model/Common/Asset.cs +++ b/SightKeeper.Domain.Model/Common/Asset.cs @@ -1,10 +1,12 @@ -using SightKeeper.Domain.Model.Detector; +using FlakeId; +using SightKeeper.Domain.Model.Detector; using SightKeeper.Domain.Model.Exceptions; namespace SightKeeper.Domain.Model.Common; public sealed class Asset { + public Id Id { get; private set; } public DataSet DataSet { get; private set; } public Screenshot Screenshot { get; private set; } public AssetUsage Usage { get; set; } diff --git a/SightKeeper.Domain.Model/Common/Game.cs b/SightKeeper.Domain.Model/Common/Game.cs index 8cf65a69..ea422b6f 100644 --- a/SightKeeper.Domain.Model/Common/Game.cs +++ b/SightKeeper.Domain.Model/Common/Game.cs @@ -1,7 +1,10 @@ -namespace SightKeeper.Domain.Model.Common; +using FlakeId; + +namespace SightKeeper.Domain.Model.Common; public sealed class Game { + public Id Id { get; private set; } public string Title { get; set; } public string ProcessName { get; set; } diff --git a/SightKeeper.Domain.Model/Common/Image.cs b/SightKeeper.Domain.Model/Common/Image.cs index 423c0a44..c7b76584 100644 --- a/SightKeeper.Domain.Model/Common/Image.cs +++ b/SightKeeper.Domain.Model/Common/Image.cs @@ -1,7 +1,10 @@ -namespace SightKeeper.Domain.Model.Common; +using FlakeId; + +namespace SightKeeper.Domain.Model.Common; public sealed class Image { + public Id Id { get; private set; } public byte[] Content { get; private set; } public Image(byte[] content) diff --git a/SightKeeper.Domain.Model/Common/ItemClass.cs b/SightKeeper.Domain.Model/Common/ItemClass.cs index ab2c9edf..6f4af203 100644 --- a/SightKeeper.Domain.Model/Common/ItemClass.cs +++ b/SightKeeper.Domain.Model/Common/ItemClass.cs @@ -1,11 +1,13 @@ using System.Diagnostics.CodeAnalysis; using CommunityToolkit.Diagnostics; +using FlakeId; using SightKeeper.Domain.Model.Detector; namespace SightKeeper.Domain.Model.Common; public sealed class ItemClass { + public Id Id { get; private set; } public DataSet DataSet { get; private set; } public string Name { get; set; } public uint Color { get; set; } diff --git a/SightKeeper.Domain.Model/DataSet/DataSet.cs b/SightKeeper.Domain.Model/DataSet/DataSet.cs index ceeae6c4..e4eea7c8 100644 --- a/SightKeeper.Domain.Model/DataSet/DataSet.cs +++ b/SightKeeper.Domain.Model/DataSet/DataSet.cs @@ -1,11 +1,13 @@ using System.Diagnostics.CodeAnalysis; using CommunityToolkit.Diagnostics; +using FlakeId; using SightKeeper.Domain.Model.Common; namespace SightKeeper.Domain.Model; public sealed class DataSet { + public Id Id { get; private set; } public string Name { get; set; } public string Description { get; set; } public Game? Game { get; set; } diff --git a/SightKeeper.Domain.Model/DataSet/Weights/Weights.cs b/SightKeeper.Domain.Model/DataSet/Weights/Weights.cs index 4408a7cd..64fefadf 100644 --- a/SightKeeper.Domain.Model/DataSet/Weights/Weights.cs +++ b/SightKeeper.Domain.Model/DataSet/Weights/Weights.cs @@ -1,9 +1,11 @@ -using SightKeeper.Domain.Model.Common; +using FlakeId; +using SightKeeper.Domain.Model.Common; namespace SightKeeper.Domain.Model; public sealed class Weights { + public Id Id { get; private set; } public DateTime CreationDate { get; private set; } public WeightsLibrary Library { get; private set; } public ONNXData ONNXData { get; private set; } diff --git a/SightKeeper.Domain.Model/DataSet/Weights/WeightsData.cs b/SightKeeper.Domain.Model/DataSet/Weights/WeightsData.cs index aa660437..2637efac 100644 --- a/SightKeeper.Domain.Model/DataSet/Weights/WeightsData.cs +++ b/SightKeeper.Domain.Model/DataSet/Weights/WeightsData.cs @@ -1,7 +1,10 @@ -namespace SightKeeper.Domain.Model; +using FlakeId; + +namespace SightKeeper.Domain.Model; public abstract class WeightsData { + public Id Id { get; private set; } public byte[] Content { get; private set; } protected WeightsData(byte[] content) diff --git a/SightKeeper.Domain.Model/DataSet/Weights/WeightsLibrary.cs b/SightKeeper.Domain.Model/DataSet/Weights/WeightsLibrary.cs index 29e46775..f49d752b 100644 --- a/SightKeeper.Domain.Model/DataSet/Weights/WeightsLibrary.cs +++ b/SightKeeper.Domain.Model/DataSet/Weights/WeightsLibrary.cs @@ -1,10 +1,12 @@ using CommunityToolkit.Diagnostics; +using FlakeId; using SightKeeper.Domain.Model.Common; namespace SightKeeper.Domain.Model; public sealed class WeightsLibrary { + public Id Id { get; private set; } public DataSet DataSet { get; private set; } public IReadOnlyCollection Weights => _weights; diff --git a/SightKeeper.Domain.Model/Detector/DetectorItem.cs b/SightKeeper.Domain.Model/Detector/DetectorItem.cs index 122bd9cd..3b41c6a0 100644 --- a/SightKeeper.Domain.Model/Detector/DetectorItem.cs +++ b/SightKeeper.Domain.Model/Detector/DetectorItem.cs @@ -1,9 +1,11 @@ -using SightKeeper.Domain.Model.Common; +using FlakeId; +using SightKeeper.Domain.Model.Common; namespace SightKeeper.Domain.Model.Detector; public sealed class DetectorItem { + public Id Id { get; private set; } public Asset Asset { get; private set; } public ItemClass ItemClass { get; set; } public Bounding Bounding { get; private set; } diff --git a/SightKeeper.Domain.Model/Profile/Profile.cs b/SightKeeper.Domain.Model/Profile/Profile.cs index d2c6fa9d..17f23c4e 100644 --- a/SightKeeper.Domain.Model/Profile/Profile.cs +++ b/SightKeeper.Domain.Model/Profile/Profile.cs @@ -1,10 +1,12 @@ using CommunityToolkit.Diagnostics; +using FlakeId; using SightKeeper.Domain.Model.Common; namespace SightKeeper.Domain.Model; public sealed class Profile { + public Id Id { get; private set; } public string Name { get; set; } public string Description { get; set; } diff --git a/SightKeeper.Domain.Model/Profile/ProfileItemClass.cs b/SightKeeper.Domain.Model/Profile/ProfileItemClass.cs index fa279ad8..bea29a52 100644 --- a/SightKeeper.Domain.Model/Profile/ProfileItemClass.cs +++ b/SightKeeper.Domain.Model/Profile/ProfileItemClass.cs @@ -1,9 +1,11 @@ -using SightKeeper.Domain.Model.Common; +using FlakeId; +using SightKeeper.Domain.Model.Common; namespace SightKeeper.Domain.Model; public sealed class ProfileItemClass { + public Id Id { get; private set; } public ItemClass ItemClass { get; private set; } public byte Index { get; internal set; } public ItemClassActivationCondition ActivationCondition { get; set; } diff --git a/SightKeeper.Domain.Model/Screenshots/Screenshot.cs b/SightKeeper.Domain.Model/Screenshots/Screenshot.cs index fba0c597..c809cbbe 100644 --- a/SightKeeper.Domain.Model/Screenshots/Screenshot.cs +++ b/SightKeeper.Domain.Model/Screenshots/Screenshot.cs @@ -1,9 +1,11 @@ -using SightKeeper.Domain.Model.Common; +using FlakeId; +using SightKeeper.Domain.Model.Common; namespace SightKeeper.Domain.Model; public sealed class Screenshot { + public Id Id { get; private set; } public Image Image { get; private set; } public DateTime CreationDate { get; private set; } public Asset? Asset { get; internal set; } diff --git a/SightKeeper.Domain.Model/Screenshots/ScreenshotsLibrary.cs b/SightKeeper.Domain.Model/Screenshots/ScreenshotsLibrary.cs index aa9a8104..f845a321 100644 --- a/SightKeeper.Domain.Model/Screenshots/ScreenshotsLibrary.cs +++ b/SightKeeper.Domain.Model/Screenshots/ScreenshotsLibrary.cs @@ -1,11 +1,13 @@ using System.Reactive.Linq; using System.Reactive.Subjects; using CommunityToolkit.Diagnostics; +using FlakeId; namespace SightKeeper.Domain.Model; public sealed class ScreenshotsLibrary { + public Id Id { get; private set; } public IObservable ScreenshotAdded => _screenshotAdded.AsObservable(); private readonly Subject _screenshotAdded = new(); public IObservable ScreenshotRemoved => _screenshotRemoved.AsObservable(); diff --git a/SightKeeper.Domain.Model/SightKeeper.Domain.Model.csproj b/SightKeeper.Domain.Model/SightKeeper.Domain.Model.csproj index 7bc7ec4b..0aff0ec0 100644 --- a/SightKeeper.Domain.Model/SightKeeper.Domain.Model.csproj +++ b/SightKeeper.Domain.Model/SightKeeper.Domain.Model.csproj @@ -8,6 +8,7 @@ + diff --git a/SightKeeper.Services/ProfilesObservableRepository.cs b/SightKeeper.Services/ProfilesObservableRepository.cs index 54c7dc4c..84c15a61 100644 --- a/SightKeeper.Services/ProfilesObservableRepository.cs +++ b/SightKeeper.Services/ProfilesObservableRepository.cs @@ -1,6 +1,7 @@ using System.Reactive.Disposables; using CommunityToolkit.Diagnostics; using DynamicData; +using Serilog; using SightKeeper.Commons; using SightKeeper.Domain.Model; using SightKeeper.Domain.Services; @@ -35,6 +36,11 @@ private void LoadProfiles(ProfilesDataAccess profilesDataAccess) { profilesDataAccess.LoadProfiles().Subscribe(AddProfile); } - private void AddProfile(Profile profile) => _profiles.Add(profile); + private void AddProfile(Profile profile) + { + Log.Debug("Profile Id: {Id}", profile.Id); + _profiles.Add(profile); + } + private void RemoveProfile(Profile profile) => Guard.IsTrue(_profiles.Remove(profile)); } \ No newline at end of file