Converting c# code to Progress

Posted by tbergman on 20-Mar-2014 20:11

I'm converting the following code snippet to Progress. I got it to work but my solution seems a bit inelegant.

ImageConverter _imageConverter = new ImageConverter();
    byte[] xByte = (byte[])_imageConverter.ConvertTo(x, typeof(byte[]));
    return xByte;

Note that the second parameter of the ConvertTo method has to be a System.Type.

What I ended up doing was defining a Byte[] and then using GetType against it. This works but I had to new a byte array and it seems like there should be a cleaner way. Is there something in Progress that's like the C# Typeof command, the Progress Type-Of statement returns a logical, not a System.Type.

DEF VAR x AS "System.Byte[]".  

x = NEW "System.Byte[]"(0).   

RETURN CAST(oConverter:ConvertTo(pImage,x:GetType()),"System.Byte[]").

All Replies

Posted by Mike Fechner on 21-Mar-2014 02:47

Progress.Util.TypeHelper:GetType("System.Byte[]").

Von meinem Windows Phone gesendet

Von: tbergman
Gesendet: ‎21.‎03.‎2014 02:11
An: TU.OE.Development@community.progress.com
Betreff: Converting c# code to Progress

Thread created by tbergman

I'm converting the following code snippet to Progress. I got it to work but my solution seems a bit inelegant.

ImageConverter _imageConverter = new ImageConverter();
    byte[] xByte = (byte[])_imageConverter.ConvertTo(x, typeof(byte[]));
    return xByte;

Note that the second parameter of the ConvertTo method has to be a System.Type.

What I ended up doing was defining a Byte[] and then using GetType against it. This works but I had to new a byte array and it seems like there should be a cleaner way. Is there something in Progress that's like the C# Typeof command, the Progress Type-Of statement returns a logical, not a System.Type.

DEF VAR x AS "System.Byte[]".  

x = NEW "System.Byte[]"(0).   

RETURN CAST(oConverter:ConvertTo(pImage,x:GetType()),"System.Byte[]").

Stop receiving emails on this subject.

Flag this post as spam/abuse.

Posted by tbergman on 21-Mar-2014 05:08

Thanks Mike, that's exactly what I was looking for.

This thread is closed