Another OT: .Net=>WB

Started by spl, December 08, 2024, 06:50:50 AM

Previous topic - Next topic

spl

This is an aside from the previous WOL thread that Tony ended quit effectively. The focus is the code for creating a byte array from hex. Curiosity for how that could be easily accomplished in .NET lead me to an unadvertised object System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary

So I can get this far
hex = '1A:2B:3C:4D:5E:6F'
ObjectClrOption('useany','System')
cvt = ObjectClrNew('System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary')
hex = StrReplace(hex,':','')
result = cvt.Parse(hex)
Message("",result)

but there is a Value Property and in PS
$result = ([System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary]::Parse($hex).Value)

will return the byte array as text. I'm sure WB CLR can return the Value property but not sure if the return from .Parse() should be treated as a pointer or an object.



Stan - formerly stanl [ex-Pundit]

td

If you look at the documentation for SoapHexBinary, Parse returns an object of type SoapHexBinary. SoapHexBinary has a property named "Value." So proper usage would be

aBytes = Result.Value
Of course, if you used WinBatch Studio, the variable types would be self-evident in the variable watch window.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

spl

I believe my original post specified that .Value was a property. So, if using your suggestion
hex = '1A:2B:3C:4D:5E:6F'
ObjectClrOption('useany','System')
cvt = ObjectClrNew('System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary')
hex = StrReplace(hex,':','')
result = cvt.Parse(hex)
aBytes = result.Value
Message("",aBytes)

you get the attached, ergo back to my original question as to how to decode the .Parse() object
Stan - formerly stanl [ex-Pundit]