pull/2/head
Harald Wolff 2019-09-26 09:41:09 +02:00
parent da04a75a1a
commit c813829b51
5 changed files with 19 additions and 17 deletions

View File

@ -116,6 +116,9 @@
<Compile Include="test\CacheTests.cs" /> <Compile Include="test\CacheTests.cs" />
<Compile Include="test\ODBTests.cs" /> <Compile Include="test\ODBTests.cs" />
<Compile Include="test\TypesTests.cs" /> <Compile Include="test\TypesTests.cs" />
<Compile Include="odb\ng\diff\Diff.cs" />
<Compile Include="odb\ng\diff\DocumentDiff.cs" />
<Compile Include="odb\ng\diff\ListDiff.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="odb\" /> <Folder Include="odb\" />

View File

@ -5,9 +5,9 @@ namespace ln.types.odb.ng.diff
public abstract class 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())) if (!src.GetType().Equals(dst.GetType()))
{ {
@ -27,14 +27,14 @@ namespace ln.types.odb.ng.diff
class SimpleDiff : 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; return DestinationValue;
} }

View File

@ -6,22 +6,22 @@ namespace ln.types.odb.ng.diff
{ {
public class DocumentDiff : Diff public class DocumentDiff : Diff
{ {
Dictionary<ODBValue, Diff> propertyDiffs = new Dictionary<ODBValue, Diff>(); Dictionary<ODBEntity, Diff> propertyDiffs = new Dictionary<ODBEntity, Diff>();
public DocumentDiff(Document src, Document dst) public DocumentDiff(Document src, Document dst)
{ {
HashSet<ODBValue> keys = new HashSet<ODBValue>(src.Keys); HashSet<ODBEntity> keys = new HashSet<ODBEntity>(src.Keys);
foreach (ODBValue key in dst.Keys) foreach (ODBEntity key in dst.Keys)
keys.Add(key); keys.Add(key);
foreach (ODBValue key in keys) foreach (ODBEntity key in keys)
{ {
if (!src[key].Equals(dst[key])) if (!src[key].Equals(dst[key]))
propertyDiffs.Add(key, Diff.Construct(src[key], 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; Document srcDocument = src as Document;

View File

@ -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(); throw new NotImplementedException();
} }

View File

@ -4,6 +4,7 @@ using ln.types.odb.values;
using System.Linq; using System.Linq;
using ln.types.odb.ng.storage.bases; using ln.types.odb.ng.storage.bases;
using ln.types.threads; using ln.types.threads;
using ln.types.odb.ng.diff;
namespace ln.types.odb.ng.storage.session namespace ln.types.odb.ng.storage.session
{ {
class SessionStorage : ChainedStorage class SessionStorage : ChainedStorage
@ -118,14 +119,12 @@ namespace ln.types.odb.ng.storage.session
if (!GetStorageTimestamp(document.ID).Equals(document.StorageTimeStamp)) if (!GetStorageTimestamp(document.ID).Equals(document.StorageTimeStamp))
{ {
Document cacheDocument = cachedDocument.CachedCopy; Document cacheDocument = cachedDocument.CachedCopy;
Document storageDocument = Storage.Load(document.ID); Document storageDocument = Storage.Load(document.ID);
DocumentChanges storageChanges = new DocumentChanges(cacheDocument, storageDocument); DocumentDiff cacheDiff = new DocumentDiff(cacheDocument, document);
DocumentChanges sessionChanges = new DocumentChanges(cacheDocument, document); DocumentDiff storageDiff = new DocumentDiff(cacheDocument, storageDocument);
Document prepare = cacheDocument.Clone() as Document;
} }