ok

alphons <alphons@heijden.com> 15 Jan 2025, 12:24
acc5a0c043b990f91c8f37e397fe2e23f75b3382
2 files changed
  • RedisGui/FormMain.cs
  • RedisGui/Helper.cs
diff --git a/RedisGui/FormMain.cs b/RedisGui/FormMain.cs
index d7eba59..1247fe8 100644
--- a/RedisGui/FormMain.cs
+++ b/RedisGui/FormMain.cs
@@ -3,8 +3,6 @@ using RedisGui.Properties;
using StackExchange.Redis;
using System.Diagnostics;
using System.Net;
-using System.Windows.Forms;
-
namespace RedisGui;
@@ -255,9 +253,18 @@ public partial class FormMain : Form
var val = lvi.SubItems[1].Text;
if ((val.StartsWith('{') && val.EndsWith('}')) || (val.StartsWith('[') && val.EndsWith(']')))
+ {
this.txtData.Text = Helper.PrettyPrintJson(val);
- else
- this.txtData.Text = val;
+ return;
+ }
+
+ if(val.Contains("*binary*"))
+ {
+ this.txtData.Text = Helper.ConvertByteArrayToHexText(lvi.Tag as byte[]);
+ return;
+ }
+
+ this.txtData.Text = val;
}
private async void Timer_Tick(object sender, EventArgs e)
diff --git a/RedisGui/Helper.cs b/RedisGui/Helper.cs
index b749b41..6bc80e5 100644
--- a/RedisGui/Helper.cs
+++ b/RedisGui/Helper.cs
@@ -1,9 +1,7 @@
-using System;
-using System.Buffers.Binary;
+using System.Buffers.Binary;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
-using System.Xml.Linq;
namespace RedisGui;
@@ -55,6 +53,7 @@ public class Helper
public static void SessionDecoder(ListView lv, string entryName, byte[] b)
{
+ lv.Tag = b;
lv.Items.Add(new ListViewItem([entryName, $"*binary* (len {b.Length})"]));
lv.Items.Add(new ListViewItem(["--------------", "--------------"]));
@@ -89,8 +88,11 @@ public class Helper
}
}
- public static string ConvertByteArrayToHexText(byte[] byteArray)
+ public static string ConvertByteArrayToHexText(byte[]? byteArray)
{
+ if (byteArray == null)
+ return "null";
+
StringBuilder hexBuilder = new();
for (int i = 0; i < byteArray.Length; i += 32)