From 0bfb0b8cc5131a00c902e7243bf10dba5b7280cc Mon Sep 17 00:00:00 2001 From: MaxXor Date: Mon, 26 Nov 2018 18:50:13 +0100 Subject: [PATCH] Remove duplicate RegistryValueToString method --- Quasar.Server/Forms/FrmRegistryEditor.cs | 22 +--------------------- Quasar.Server/Registry/RegValueHelper.cs | 8 ++++---- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/Quasar.Server/Forms/FrmRegistryEditor.cs b/Quasar.Server/Forms/FrmRegistryEditor.cs index b2ef318c..c724873b 100644 --- a/Quasar.Server/Forms/FrmRegistryEditor.cs +++ b/Quasar.Server/Forms/FrmRegistryEditor.cs @@ -361,7 +361,7 @@ private void ChangeValue(object sender, string keyPath, RegValueData value) var valueItem = lstRegistryValues.Items.Cast() .SingleOrDefault(item => item.Name == value.Name); if (valueItem != null) - valueItem.Data = RegistryValueToString(value); + valueItem.Data = RegValueHelper.RegistryValueToString(value); } tvRegistryDirectory.SelectedNode = key; @@ -374,26 +374,6 @@ private void ChangeRegistryValue(RegValueData source, RegValueData dest) dest.Data = source.Data; } - private string RegistryValueToString(RegValueData value) - { - switch (value.Kind) - { - case RegistryValueKind.Binary: - return value.Data.Length > 0 ? BitConverter.ToString(value.Data).Replace("-", " ").ToLower() : "(zero-length binary value)"; - case RegistryValueKind.MultiString: - return string.Join(" ", ByteConverter.ToStringArray(value.Data)); - case RegistryValueKind.DWord: // show hexadecimal and decimal - return $"0x{value.Data:x8} ({ByteConverter.ToUInt32(value.Data).ToString()})"; - case RegistryValueKind.QWord: // show hexadecimal and decimal - return $"0x{value.Data:x8} ({ByteConverter.ToUInt64(value.Data).ToString()})"; - case RegistryValueKind.String: - case RegistryValueKind.ExpandString: - return ByteConverter.ToString(value.Data); - default: - return string.Empty; - } - } - private void UpdateLstRegistryValues(TreeNode node) { selectedStripStatusLabel.Text = node.FullPath; diff --git a/Quasar.Server/Registry/RegValueHelper.cs b/Quasar.Server/Registry/RegValueHelper.cs index 04eb6818..71110d95 100644 --- a/Quasar.Server/Registry/RegValueHelper.cs +++ b/Quasar.Server/Registry/RegValueHelper.cs @@ -1,7 +1,7 @@ -using System; -using Microsoft.Win32; +using Microsoft.Win32; using Quasar.Common.Models; using Quasar.Common.Utilities; +using System; namespace Quasar.Server.Registry { @@ -29,10 +29,10 @@ public static string RegistryValueToString(RegValueData value) return string.Join(" ", ByteConverter.ToStringArray(value.Data)); case RegistryValueKind.DWord: var dword = ByteConverter.ToUInt32(value.Data); - return $"0x{dword:x8} ({dword.ToString()})"; // show hexadecimal and decimal + return $"0x{dword:x8} ({dword})"; // show hexadecimal and decimal case RegistryValueKind.QWord: var qword = ByteConverter.ToUInt64(value.Data); - return $"0x{qword:x8} ({qword.ToString()})"; // show hexadecimal and decimal + return $"0x{qword:x8} ({qword})"; // show hexadecimal and decimal case RegistryValueKind.String: case RegistryValueKind.ExpandString: return ByteConverter.ToString(value.Data);