diff --git a/BookAStar/BookAStar/BookAStar.csproj b/BookAStar/BookAStar/BookAStar.csproj index 9bd62926..908d00f0 100644 --- a/BookAStar/BookAStar/BookAStar.csproj +++ b/BookAStar/BookAStar/BookAStar.csproj @@ -43,6 +43,8 @@ + + diff --git a/BookAStar/BookAStar/Helpers/LocaLEntity.cs b/BookAStar/BookAStar/Helpers/LocaLEntity.cs index 2f86ecdb..6ec0f775 100644 --- a/BookAStar/BookAStar/Helpers/LocaLEntity.cs +++ b/BookAStar/BookAStar/Helpers/LocaLEntity.cs @@ -1,19 +1,23 @@  +using BookAStar.Interfaces; using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; namespace BookAStar { - public class LocalEntity : ObservableCollection where K : IEquatable + public class LocalEntity : ObservableCollection, ILocalEntity where K : IEquatable { public V CurrentItem { get; protected set; } - protected Func GetKey { get; set; } + public Func GetKey { get; set; } public LocalEntity(Func getKey) : base() { if (getKey == null) throw new InvalidOperationException(); GetKey = getKey; + IList l = this; } + public virtual void Merge(V item) { var key = GetKey(item); @@ -29,6 +33,11 @@ namespace BookAStar CurrentItem = this.Single(x => GetKey(x).Equals(key)); return CurrentItem; } + + public void Load() + { + this.Populate(); + } } } \ No newline at end of file diff --git a/BookAStar/BookAStar/Interfaces/ILocalEntity.cs b/BookAStar/BookAStar/Interfaces/ILocalEntity.cs new file mode 100644 index 00000000..38988e9f --- /dev/null +++ b/BookAStar/BookAStar/Interfaces/ILocalEntity.cs @@ -0,0 +1,21 @@ +using System; + +namespace BookAStar +{ + public interface ILoadable + { + void Load(); + } + + public interface ILocalEntity : ILoadable where K : IEquatable + { + V CurrentItem { get; } + + Func GetKey { get; set; } + + V LocalGet(K key); + + void Merge(V item); + + } +} \ No newline at end of file