public object Read(byte[] buffer, int index)
        {
            var start = index;
            var count = length;

            if (trim)
            {
                BytesHelper.TrimRange(buffer, ref start, ref count, padding, filler);
            }

            return(encoding.GetString(buffer, start, count));
        }
Exemple #2
0
        public object Read(byte[] buffer, int index)
        {
            var start = index;
            var count = length;

            if (trim)
            {
                BytesHelper.TrimRange(buffer, ref start, ref count, padding, filler);
            }

            var value = encoding.GetString(buffer, start, count);

            if ((value.Length > 0) && Int32.TryParse(value, style, provider, out var result))
            {
                return(convertEnumType is null ? result : Enum.ToObject(convertEnumType, result));
            }

            return(defaultValue);
        }
Exemple #3
0
        public object Read(byte[] buffer, int index)
        {
            var start = index;
            var count = length;

            if (trim)
            {
                BytesHelper.TrimRange(buffer, ref start, ref count, padding, filler);
            }

            var value = encoding.GetString(buffer, start, count);

            if ((value.Length > 0) && Decimal.TryParse(value, style, provider, out var result))
            {
                return(result);
            }

            return(defaultValue);
        }