diff options
author | Jeffrey Stedfast <jeff@xamarin.com> | 2015-03-17 21:32:05 +0300 |
---|---|---|
committer | Jeffrey Stedfast <jeff@xamarin.com> | 2015-03-17 21:33:26 +0300 |
commit | 1009a20f171072dab553abba061a6724028ef4c2 (patch) | |
tree | 7254347d294d6f252ee8e2533fc226f7dbff12e5 /main/src/addins/MonoDevelop.HexEditor | |
parent | 58fa05a3e036fb9aea4659d9503a25634cdb05ce (diff) |
[Debugger] Add support for visualizing System.IO.MemoryStream and NSData
Diffstat (limited to 'main/src/addins/MonoDevelop.HexEditor')
-rw-r--r-- | main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorVisualizer.cs | 65 |
1 files changed, 42 insertions, 23 deletions
diff --git a/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorVisualizer.cs b/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorVisualizer.cs index 4402617206..e63dee04d6 100644 --- a/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorVisualizer.cs +++ b/main/src/addins/MonoDevelop.HexEditor/MonoDevelop.HexEditor/HexEditorVisualizer.cs @@ -48,27 +48,35 @@ namespace MonoDevelop.HexEditor public override bool CanVisualize (ObjectValue val) { - if (val.TypeName != null && val.TypeName.EndsWith ("Foundation.NSData")) - return true; switch (val.TypeName) { - case "sbyte[]": return true; - case "byte[]": return true; - case "char[]": return true; - case "string": return true; - default: return false; + case "MonoTouch.Foundation.NSData": + case "MonoMac.Foundation.NSData": + case "System.IO.MemoryStream": + case "Foundation.NSData": + case "sbyte[]": + case "byte[]": + case "char[]": + case "string": + return true; + default: + return false; } } public override bool IsDefaultVisualizer (ObjectValue val) { - if (val.TypeName != null && val.TypeName.EndsWith ("Foundation.NSData")) - return true; switch (val.TypeName) { + case "MonoTouch.Foundation.NSData": + case "MonoMac.Foundation.NSData": + case "System.IO.MemoryStream": + case "Foundation.NSData": case "sbyte[]": - case "byte[]": return true; + case "byte[]": + return true; case "char[]": - case "string": return false; - default: return false; + case "string": + default: + return false; } } @@ -85,28 +93,39 @@ namespace MonoDevelop.HexEditor options.AllowTargetInvoke = true; options.ChunkRawStrings = true; - IBuffer buffer = null; hexEditor = new Mono.MHex.HexEditorDebugger (); + RawValueString rawString; + RawValueArray rawArray; + IBuffer buffer = null; - if (val.TypeName != null && val.TypeName.EndsWith ("Foundation.NSData")) { - var raw = (RawValueArray)((RawValue)val.GetRawValue ()).CallMethod ("ToArray"); - buffer = new RawByteArrayBuffer (raw); - } else if (val.TypeName != "string") { - var raw = (RawValueArray)val.GetRawValue (options); + switch (val.TypeName) { + case "MonoTouch.Foundation.NSData": + case "MonoMac.Foundation.NSData": + case "System.IO.MemoryStream": + case "Foundation.NSData": + var stream = (RawValue) val.GetRawValue (options); + rawArray = (RawValueArray) stream.CallMethod ("ToArray"); + buffer = new RawByteArrayBuffer (rawArray); + break; + case "string": + rawString = (RawValueString) val.GetRawValue (options); + buffer = new RawStringBuffer (rawString); + break; + default: + rawArray = (RawValueArray) val.GetRawValue (options); switch (val.TypeName) { case "sbyte[]": - buffer = new RawSByteArrayBuffer (raw); + buffer = new RawSByteArrayBuffer (rawArray); break; case "char[]": - buffer = new RawCharArrayBuffer (raw); + buffer = new RawCharArrayBuffer (rawArray); break; case "byte[]": - buffer = new RawByteArrayBuffer (raw); + buffer = new RawByteArrayBuffer (rawArray); break; } - } else { - buffer = new RawStringBuffer ((RawValueString)val.GetRawValue (options)); + break; } hexEditor.HexEditorData.Buffer = buffer; |