示例#1
0
        public decimal GetDecimal()
        {
            if (_cacheSet)
            {
                return((decimal)_dataCache);
            }

            string str = _dataAsString;

            if (!DbfFieldType.IsFloatingPoint(_fieldType))
            {
                throw new DbfColumnTypeMismatchException(_fieldType, str, typeof(decimal));
            }

            decimal result;

            if (!decimal.TryParse(str, NumberStyles.Number, null, out result))
            {
                throw new DbfColumnTypeMismatchException(_fieldType, str, typeof(decimal));
            }

            _cacheSet  = true;
            _dataCache = result;

            return(result);
        }
示例#2
0
 internal void AddHeader(DbfHeader header)
 {
     if (header == null)
     {
         return;
     }
     if (DbfFieldType.IsFloatingPoint(header.FieldType) && header.NumDecimalPlaces == 0)
     {
         header.FieldType = DbfFieldType.Integer;
     }
     _headers.Add(header);
 }