public static string DecodeString(this IBinaryDecoder decoder, string encodedString, Encoding encoding = null)
        {
            if (encoding is null)
            {
                encoding = Encoding.UTF8;
            }

            return(encoding.GetString(decoder.Decode(encodedString, encoding)));
        }
        public static byte[] Decode(this IBinaryDecoder decoder, string encodedString, Encoding encoding = null)
        {
            if (encoding is null)
            {
                encoding = Encoding.UTF8;
            }

            byte[] encodedBytes = encoding.GetBytes(encodedString);

            return(decoder.Decode(encodedBytes));
        }
        public BinarySoftwareDetectorWorker(IEnumerable <IProductBinarySoftwareDetector> detectors, IBinaryDecoder binaryDecoder, byte[] prefix, byte[] inBuffer, int startIndex, int endIndex, uint?[] offsets)
            : base(detectors)
        {
            this.inBuffer = inBuffer;
            if (offsets != null)
            {
                var prefixLength = prefix != null
                    ? prefix.Length
                    : 0;
                this.encBuffer = new byte[inBuffer.Length - prefixLength];
                Array.Copy(inBuffer, prefixLength, encBuffer, 0, encBuffer.Length);
                this.decBuffer = new byte[encBuffer.Length];
                this.decode    = o => binaryDecoder.Decode(encBuffer, decBuffer, o.Value);

                this.offsets = new uint?[endIndex - startIndex];
                for (var i = 0; i < this.offsets.Length; i++)
                {
                    this.offsets[i] = offsets[i + startIndex];
                }
            }
        }
 public static byte[] Decode(this IBinaryDecoder decoder, byte[] encodedBytes, int startIndex)
 {
     return(decoder.Decode(encodedBytes, startIndex, encodedBytes.Length - startIndex));
 }
 public static byte[] Decode(this IBinaryDecoder decoder, byte[] encodedBytes)
 {
     return(decoder.Decode(encodedBytes, 0, encodedBytes.Length));
 }