Expose legacy catalog as read port
This commit is contained in:
parent
23a5241a7d
commit
c9f6002ff2
9 changed files with 42 additions and 34 deletions
|
|
@ -78,21 +78,21 @@ public class DatabaseLinkBase
|
|||
public Guid LinkID;
|
||||
|
||||
[IgnoreMember]
|
||||
private static LegacyCatalogCache CatalogCache { get; set; }
|
||||
private static ILegacyCatalogReader Catalog { get; set; }
|
||||
|
||||
protected static T ResolveLegacyCatalog<T>(Guid linkId) where T : DatabaseEntry
|
||||
{
|
||||
if (CatalogCache == null)
|
||||
if (Catalog == null)
|
||||
throw new InvalidOperationException("Legacy DatabaseLink resolution is not bound. Open LegacyCatalogBoundary before reading legacy catalog object graphs.");
|
||||
|
||||
return CatalogCache.Get<T>(linkId);
|
||||
return Catalog.Get<T>(linkId);
|
||||
}
|
||||
|
||||
public static void BindLegacyCatalog(LegacyCatalogCache cache)
|
||||
public static void BindLegacyCatalog(ILegacyCatalogReader catalog)
|
||||
{
|
||||
if (cache == null) throw new ArgumentNullException(nameof(cache));
|
||||
if (catalog == null) throw new ArgumentNullException(nameof(catalog));
|
||||
|
||||
CatalogCache = cache;
|
||||
Catalog = catalog;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,14 @@ using System.Reflection;
|
|||
using MessagePack;
|
||||
using UniRx;
|
||||
|
||||
public class LegacyCatalogCache
|
||||
public interface ILegacyCatalogReader
|
||||
{
|
||||
DatabaseEntry Get(Guid guid);
|
||||
T Get<T>(Guid guid) where T : DatabaseEntry;
|
||||
IEnumerable<T> GetAll<T>() where T : DatabaseEntry;
|
||||
}
|
||||
|
||||
public class LegacyCatalogCache : ILegacyCatalogReader
|
||||
{
|
||||
|
||||
private readonly object addLock = new object();
|
||||
|
|
|
|||
Loading…
Reference in a new issue