From 95dacdd6da51aa2e5a98acd98a2fa009e2eb364f Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 14 Apr 2017 16:19:39 -0400 Subject: [PATCH] minor optimizations --- .../Serializers/XmlConnectionsDeserializer.cs | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/mRemoteV1/Config/Serializers/XmlConnectionsDeserializer.cs b/mRemoteV1/Config/Serializers/XmlConnectionsDeserializer.cs index bcb518bb4..3c6e09ca2 100644 --- a/mRemoteV1/Config/Serializers/XmlConnectionsDeserializer.cs +++ b/mRemoteV1/Config/Serializers/XmlConnectionsDeserializer.cs @@ -148,14 +148,11 @@ namespace mRemoteNG.Config.Serializers { if (_confVersion >= 2.6) { - BlockCipherEngines engine; - Enum.TryParse(connectionsRootElement?.Attributes["EncryptionEngine"].Value, out engine); + Enum.TryParse(connectionsRootElement?.Attributes["EncryptionEngine"].Value, out BlockCipherEngines engine); - BlockCipherModes mode; - Enum.TryParse(connectionsRootElement?.Attributes["BlockCipherMode"].Value, out mode); + Enum.TryParse(connectionsRootElement?.Attributes["BlockCipherMode"].Value, out BlockCipherModes mode); - int keyDerivationIterations; - int.TryParse(connectionsRootElement?.Attributes["KdfIterations"].Value, out keyDerivationIterations); + int.TryParse(connectionsRootElement?.Attributes["KdfIterations"].Value, out int keyDerivationIterations); _decryptor = new XmlConnectionsDecryptor(engine, mode, rootNodeInfo) { @@ -179,22 +176,24 @@ namespace mRemoteNG.Config.Serializers var treeNodeTypeString = xmlNode.Attributes?["Type"].Value ?? "connection"; var nodeType = (TreeNodeType)Enum.Parse(typeof(TreeNodeType), treeNodeTypeString, true); - if (nodeType == TreeNodeType.Connection) + // ReSharper disable once SwitchStatementMissingSomeCases + switch (nodeType) { - var connectionInfo = GetConnectionInfoFromXml(xmlNode); - parentContainer.AddChild(connectionInfo); - } - else if (nodeType == TreeNodeType.Container) - { - var containerInfo = new ContainerInfo(); + case TreeNodeType.Connection: + var connectionInfo = GetConnectionInfoFromXml(xmlNode); + parentContainer.AddChild(connectionInfo); + break; + case TreeNodeType.Container: + var containerInfo = new ContainerInfo(); - if (_confVersion >= 0.9) - containerInfo.CopyFrom(GetConnectionInfoFromXml(xmlNode)); - if (_confVersion >= 0.8) - containerInfo.IsExpanded = xmlNode.Attributes?["Expanded"].Value == "True"; + if (_confVersion >= 0.9) + containerInfo.CopyFrom(GetConnectionInfoFromXml(xmlNode)); + if (_confVersion >= 0.8) + containerInfo.IsExpanded = xmlNode.Attributes?["Expanded"].Value == "True"; - parentContainer.AddChild(containerInfo); - AddNodesFromXmlRecursive(xmlNode, containerInfo); + parentContainer.AddChild(containerInfo); + AddNodesFromXmlRecursive(xmlNode, containerInfo); + break; } } } @@ -331,7 +330,9 @@ namespace mRemoteNG.Config.Serializers case 3: connectionInfo.Colors = ProtocolRDP.RDPColors.Colors32Bit; break; + // ReSharper disable once RedundantCaseLabel case 4: + default: connectionInfo.Colors = ProtocolRDP.RDPColors.Colors15Bit; break; }