diff --git a/ln.types.csproj b/ln.types.csproj index df7b82a..e7d1584 100644 --- a/ln.types.csproj +++ b/ln.types.csproj @@ -116,6 +116,9 @@ + + + diff --git a/odb/ng/diff/Diff.cs b/odb/ng/diff/Diff.cs index 08a43c5..b784f69 100644 --- a/odb/ng/diff/Diff.cs +++ b/odb/ng/diff/Diff.cs @@ -5,9 +5,9 @@ namespace ln.types.odb.ng.diff public abstract class Diff { - public abstract ODBValue Apply(ODBValue src); + public abstract ODBEntity Apply(ODBEntity src); - public static Diff Construct(ODBValue src,ODBValue dst) + public static Diff Construct(ODBEntity src,ODBEntity dst) { if (!src.GetType().Equals(dst.GetType())) { @@ -27,14 +27,14 @@ namespace ln.types.odb.ng.diff class SimpleDiff : Diff { - public ODBValue DestinationValue { get; } + public ODBEntity DestinationValue { get; } - public SimpleDiff(ODBValue dst) + public SimpleDiff(ODBEntity dst) { - DestinationValue = dst.Clone(); + DestinationValue = dst; } - public override ODBValue Apply(ODBValue src) + public override ODBEntity Apply(ODBEntity src) { return DestinationValue; } diff --git a/odb/ng/diff/DocumentDiff.cs b/odb/ng/diff/DocumentDiff.cs index 8d4f279..d2c1287 100644 --- a/odb/ng/diff/DocumentDiff.cs +++ b/odb/ng/diff/DocumentDiff.cs @@ -6,22 +6,22 @@ namespace ln.types.odb.ng.diff { public class DocumentDiff : Diff { - Dictionary propertyDiffs = new Dictionary(); + Dictionary propertyDiffs = new Dictionary(); public DocumentDiff(Document src, Document dst) { - HashSet keys = new HashSet(src.Keys); - foreach (ODBValue key in dst.Keys) + HashSet keys = new HashSet(src.Keys); + foreach (ODBEntity key in dst.Keys) keys.Add(key); - foreach (ODBValue key in keys) + foreach (ODBEntity key in keys) { if (!src[key].Equals(dst[key])) propertyDiffs.Add(key, Diff.Construct(src[key], dst[key])); } } - public override ODBValue Apply(ODBValue src) + public override ODBEntity Apply(ODBEntity src) { Document srcDocument = src as Document; diff --git a/odb/ng/diff/ListDiff.cs b/odb/ng/diff/ListDiff.cs index 2b81f64..d0fe63f 100644 --- a/odb/ng/diff/ListDiff.cs +++ b/odb/ng/diff/ListDiff.cs @@ -11,7 +11,7 @@ namespace ln.types.odb.ng.diff } - public override ODBValue Apply(ODBValue src) + public override ODBEntity Apply(ODBEntity src) { throw new NotImplementedException(); } diff --git a/odb/ng/storage/session/SessionStorage.cs b/odb/ng/storage/session/SessionStorage.cs index 2ff37a3..22f9667 100644 --- a/odb/ng/storage/session/SessionStorage.cs +++ b/odb/ng/storage/session/SessionStorage.cs @@ -4,6 +4,7 @@ using ln.types.odb.values; using System.Linq; using ln.types.odb.ng.storage.bases; using ln.types.threads; +using ln.types.odb.ng.diff; namespace ln.types.odb.ng.storage.session { class SessionStorage : ChainedStorage @@ -118,14 +119,12 @@ namespace ln.types.odb.ng.storage.session if (!GetStorageTimestamp(document.ID).Equals(document.StorageTimeStamp)) { Document cacheDocument = cachedDocument.CachedCopy; - Document storageDocument = Storage.Load(document.ID); - DocumentChanges storageChanges = new DocumentChanges(cacheDocument, storageDocument); - DocumentChanges sessionChanges = new DocumentChanges(cacheDocument, document); - - Document prepare = cacheDocument.Clone() as Document; + DocumentDiff cacheDiff = new DocumentDiff(cacheDocument, document); + DocumentDiff storageDiff = new DocumentDiff(cacheDocument, storageDocument); + }