From 3308f1146c81a29684dd48020ea7779793b58b33 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 14 Apr 2017 15:50:20 -0400 Subject: [PATCH] load expanded data properly and minor optimization --- .../Serializers/DataTableDeserializer.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/mRemoteV1/Config/Serializers/DataTableDeserializer.cs b/mRemoteV1/Config/Serializers/DataTableDeserializer.cs index 493e9da1..31df1aa2 100644 --- a/mRemoteV1/Config/Serializers/DataTableDeserializer.cs +++ b/mRemoteV1/Config/Serializers/DataTableDeserializer.cs @@ -43,10 +43,16 @@ namespace mRemoteNG.Config.Serializers var nodeList = new List(); foreach (DataRow row in _dataTable.Rows) { - if ((string)row["Type"] == "Connection") + // ReSharper disable once SwitchStatementMissingSomeCases + switch ((string)row["Type"]) + { + case "Connection": nodeList.Add(DeserializeConnectionInfo(row)); - else if ((string)row["Type"] == "Container") + break; + case "Container": nodeList.Add(DeserializeContainerInfo(row)); + break; + } } return nodeList; } @@ -69,8 +75,15 @@ namespace mRemoteNG.Config.Serializers { connectionInfo.Name = (string)dataRow["Name"]; connectionInfo.ConstantID = (string)dataRow["ConstantID"]; + + // This throws a NPE - Parent is a connectionInfo object which will be null at this point. + // The Parent object is linked properly later in CreateNodeHierarchy() //connectionInfo.Parent.ConstantID = (string)dataRow["ParentID"]; - //connectionInfo is ContainerInfo ? ((ContainerInfo)connectionInfo).IsExpanded.ToString() : "" = dataRow["Expanded"]; + + var info = connectionInfo as ContainerInfo; + if(info != null) + info.IsExpanded = (bool)dataRow["Expanded"]; + connectionInfo.Description = (string)dataRow["Description"]; connectionInfo.Icon = (string)dataRow["Icon"]; connectionInfo.Panel = (string)dataRow["Panel"];