Remove duplicate RegistryValueToString method

This commit is contained in:
MaxXor 2018-11-26 18:50:13 +01:00
parent 3741836281
commit 0bfb0b8cc5
2 changed files with 5 additions and 25 deletions

View File

@ -361,7 +361,7 @@ private void ChangeValue(object sender, string keyPath, RegValueData value)
var valueItem = lstRegistryValues.Items.Cast<RegistryValueLstItem>() var valueItem = lstRegistryValues.Items.Cast<RegistryValueLstItem>()
.SingleOrDefault(item => item.Name == value.Name); .SingleOrDefault(item => item.Name == value.Name);
if (valueItem != null) if (valueItem != null)
valueItem.Data = RegistryValueToString(value); valueItem.Data = RegValueHelper.RegistryValueToString(value);
} }
tvRegistryDirectory.SelectedNode = key; tvRegistryDirectory.SelectedNode = key;
@ -374,26 +374,6 @@ private void ChangeRegistryValue(RegValueData source, RegValueData dest)
dest.Data = source.Data; 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) private void UpdateLstRegistryValues(TreeNode node)
{ {
selectedStripStatusLabel.Text = node.FullPath; selectedStripStatusLabel.Text = node.FullPath;

View File

@ -1,7 +1,7 @@
using System; using Microsoft.Win32;
using Microsoft.Win32;
using Quasar.Common.Models; using Quasar.Common.Models;
using Quasar.Common.Utilities; using Quasar.Common.Utilities;
using System;
namespace Quasar.Server.Registry namespace Quasar.Server.Registry
{ {
@ -29,10 +29,10 @@ public static string RegistryValueToString(RegValueData value)
return string.Join(" ", ByteConverter.ToStringArray(value.Data)); return string.Join(" ", ByteConverter.ToStringArray(value.Data));
case RegistryValueKind.DWord: case RegistryValueKind.DWord:
var dword = ByteConverter.ToUInt32(value.Data); 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: case RegistryValueKind.QWord:
var qword = ByteConverter.ToUInt64(value.Data); 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.String:
case RegistryValueKind.ExpandString: case RegistryValueKind.ExpandString:
return ByteConverter.ToString(value.Data); return ByteConverter.ToString(value.Data);