コード例 #1
0
ファイル: DbfColumn.cs プロジェクト: Zonciu/dbfreader
        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
ファイル: DbfTable.cs プロジェクト: Zonciu/dbfreader
 internal void AddHeader(DbfHeader header)
 {
     if (header == null)
     {
         return;
     }
     if (DbfFieldType.IsFloatingPoint(header.FieldType) && header.NumDecimalPlaces == 0)
     {
         header.FieldType = DbfFieldType.Integer;
     }
     _headers.Add(header);
 }