Start adding server support

This commit is contained in:
2025-09-24 21:08:59 -04:00
parent 9e2e7aabe8
commit 4e721efa55
47 changed files with 1652 additions and 266 deletions

View File

@@ -7,18 +7,5 @@ public static class Database
public static string DatabaseFile { get; set; }
public static string DatabasePath { get; set; }
public static FeedCenterEntities Entities { get; set; }
public static bool Exists => File.Exists(DatabaseFile);
public static bool Loaded { get; set; }
public static void Load()
{
if (Loaded) return;
Entities = new FeedCenterEntities();
Loaded = true;
}
}

View File

@@ -4,24 +4,17 @@ using System.Collections.Specialized;
namespace FeedCenter.Data;
public class RealmObservableCollection<T> : ObservableCollection<T> where T : IRealmObject
public class RealmObservableCollection<T>(Realm realm) : ObservableCollection<T>(realm.All<T>()) where T : IRealmObject
{
private readonly Realm _realm;
public RealmObservableCollection(Realm realm) : base(realm.All<T>())
{
_realm = realm;
}
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (e.OldItems != null)
foreach (T item in e.OldItems)
_realm.Remove(item);
realm.Remove(item);
if (e.NewItems != null)
foreach (T item in e.NewItems)
_realm.Add(item);
realm.Add(item);
base.OnCollectionChanged(e);
}