diff --git a/project/code/LGS/Database/Chunk.cs b/project/code/LGS/Database/Chunk.cs index b008329..686f190 100644 --- a/project/code/LGS/Database/Chunk.cs +++ b/project/code/LGS/Database/Chunk.cs @@ -65,4 +65,9 @@ public class GenericChunk : IChunk { writer.Write(Data); } +} + +public interface IMergable +{ + public abstract void Merge(IMergable other); } \ No newline at end of file diff --git a/project/code/LGS/Database/Chunks/Link.cs b/project/code/LGS/Database/Chunks/Link.cs index 1a78b18..b079e64 100644 --- a/project/code/LGS/Database/Chunks/Link.cs +++ b/project/code/LGS/Database/Chunks/Link.cs @@ -34,7 +34,7 @@ public record LinkId } } -public class LinkChunk : IChunk +public class LinkChunk : IChunk, IMergable { public record Link { @@ -68,9 +68,15 @@ public class LinkChunk : IChunk { throw new System.NotImplementedException(); } + + public void Merge(IMergable other) + { + links.AddRange(((LinkChunk)other).links); + } } -public class LinkDataMetaProp : IChunk +// TODO: This should be generic like Property +public class LinkDataMetaProp : IChunk, IMergable { public record LinkData { @@ -102,4 +108,9 @@ public class LinkDataMetaProp : IChunk { throw new System.NotImplementedException(); } + + public void Merge(IMergable other) + { + linkData.AddRange(((LinkDataMetaProp)other).linkData); + } } \ No newline at end of file diff --git a/project/code/LGS/Database/Chunks/Property.cs b/project/code/LGS/Database/Chunks/Property.cs index 147f722..005b883 100644 --- a/project/code/LGS/Database/Chunks/Property.cs +++ b/project/code/LGS/Database/Chunks/Property.cs @@ -18,7 +18,7 @@ public class Property } } -public class PropertyChunk : IChunk where T : Property, new() +public class PropertyChunk : IChunk, IMergable where T : Property, new() { public ChunkHeader Header { get; set; } public List properties; @@ -38,6 +38,11 @@ public class PropertyChunk : IChunk where T : Property, new() { throw new System.NotImplementedException(); } + + public void Merge(IMergable other) + { + properties.AddRange(((PropertyChunk)other).properties); + } } public class PropGeneric : Property