Exemple #1
0
        /// <summary>
        /// Converts an encoded number string to a list of double values
        /// </summary>
        /// <param name="stringOperand"></param>
        /// <returns></returns>
        public static List <double> Decode(StringOperand stringOperand)
        {
            byte[] bytes = null;

            switch (stringOperand.Type)
            {
            case StringType.Standard:
            {
                throw new Exception("Encoded Number String expected");
            }

            case StringType.Hex:
            {
                bytes = new byte[stringOperand.Length];

                for (int i = 0; i < stringOperand.Length; i++)
                {
                    bytes[i] = (byte)stringOperand.Value[i];
                }
            }
            break;

            case StringType.AsciiBase85:
            {
                bytes = Ascii85Decoder.Decode(stringOperand.Value);
                break;
            }
            }

            return(DecodeWorker(bytes));
        }
        /// <summary>
        /// Convert the given encoded string to a byte array
        /// <summary>
        private static byte[] GetBytes(StringOperand stringOp)
        {
            byte[] bytes;

            switch (stringOp.Type)
            {
            case StringType.Hex:
            {
                bytes = new byte[stringOp.Length];

                for (int i = 0; i < stringOp.Length; i++)
                {
                    bytes[i] = (byte)stringOp.Value[i];
                }

                break;
            }

            case StringType.AsciiBase85:
            {
                bytes = Ascii85Decoder.Decode(stringOp.Value);
                break;
            }

            default:
            {
                throw new Exception("Encoded Number String expected");
            }
            }

            return(bytes);
        }