Skip to content

Commit

Permalink
Closes #46
Browse files Browse the repository at this point in the history
  • Loading branch information
andreashuber-lawo committed Jun 16, 2017
1 parent 13ac3f5 commit 792d38e
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions Lawo.EmberPlusSharp/Glow/GlowLogConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down Expand Up @@ -378,14 +385,29 @@ private void WriteConnections(object value)

foreach (var connection in (IReadOnlyDictionary<int, ObservableCollection<int>>)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<int, ObservableCollection<int>> 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<int, ObservableCollection<int>> connection)
{
this.writer.WriteStartElement("Connection");
this.writer.WriteAttributeString("target", connection.Key.ToString(InvariantCulture));
this.writer.WriteAttributeString("sources", Join(" ", connection.Value));
this.writer.WriteEndElement();
}
}
}
}

0 comments on commit 792d38e

Please sign in to comment.