Resolved #42: Input string was not in a correct format.

This commit is contained in:
Michael Grafnetter 2017-04-19 16:42:14 +02:00
parent 8bbd278b69
commit 7bc6a813eb
1 changed files with 16 additions and 3 deletions

View File

@ -13,8 +13,21 @@ namespace DSInternals.PowerShell
{ {
public override object Transform(EngineIntrinsics engineIntrinsics, object inputData) public override object Transform(EngineIntrinsics engineIntrinsics, object inputData)
{ {
// Try to interpret the value as a HEX string string hexString;
string hexString = inputData as string;
// Check if inputData is a String encapsulated in an PSObject
PSObject psObject = inputData as PSObject;
if(psObject != null)
{
hexString = psObject.BaseObject as string;
}
else
{
// We are not dealing with an PSObject, so try to interpret it as a String
hexString = inputData as string;
}
// Now try to interpret the value as a HEX string
if (hexString != null) if (hexString != null)
{ {
// Parse the hex data // Parse the hex data
@ -22,7 +35,7 @@ namespace DSInternals.PowerShell
} }
else else
{ {
// We cannot parse the data as hex string so let system try to do the conversion to byte[]. // We cannot parse the data as (encapsulated) hex string so we let the system try to do the conversion to byte[].
return inputData; return inputData;
} }
} }