diff --git a/Lawo.EmberPlusSharp/Glow/GlowLogConverter.cs b/Lawo.EmberPlusSharp/Glow/GlowLogConverter.cs index 42d02300..9f3f5d2b 100644 --- a/Lawo.EmberPlusSharp/Glow/GlowLogConverter.cs +++ b/Lawo.EmberPlusSharp/Glow/GlowLogConverter.cs @@ -177,7 +177,14 @@ private void Add(IElement element) } else { - this.WriteInitSequence((IMatrix)element); + var matrix = (IMatrix)element; + this.WriteInitSequence(matrix); + + foreach (var connection in matrix.Connections) + { + connection.Value.CollectionChanged += + (s, e) => this.WriteConnection(matrix, connection); + } } } } @@ -378,14 +385,29 @@ private void WriteConnections(object value) foreach (var connection in (IReadOnlyDictionary>)value) { - this.writer.WriteStartElement("Connection"); - this.writer.WriteAttributeString("target", connection.Key.ToString(InvariantCulture)); - this.writer.WriteAttributeString("sources", Join(" ", connection.Value)); - this.writer.WriteEndElement(); + this.WriteConnectionImpl(connection); } this.writer.WriteEndElement(); } + + private void WriteConnection(IMatrix matrix, KeyValuePair> connection) + { + this.writer.WriteStartElement("Set"); + var fieldName = LowerFirst(nameof(IMatrix.Connections)); + this.writer.WriteAttributeString("path", matrix.GetPath() + "." + fieldName); + + this.WriteConnectionImpl(connection); + this.writer.WriteEndElement(); + } + + private void WriteConnectionImpl(KeyValuePair> connection) + { + this.writer.WriteStartElement("Connection"); + this.writer.WriteAttributeString("target", connection.Key.ToString(InvariantCulture)); + this.writer.WriteAttributeString("sources", Join(" ", connection.Value)); + this.writer.WriteEndElement(); + } } } }