예제 #1
0
 protected void CheckField(DbfField field, string name, DbfType type, int length, int?decimals = null)
 {
     Assert.AreEqual(name, field.Name);
     Assert.AreEqual(type, field.DbfType);
     Assert.AreEqual(length, field.FieldLength);
     if (decimals != null)
     {
         Assert.AreEqual(decimals, field.Decimals);
     }
 }
예제 #2
0
        public DbfField(DbfReader.DbfFieldStructure field)
        {
            _name        = field.Name;
            _dbfType     = (DbfType)field.TypeChar;
            _fieldLength = field.FieldLength;
            var isChar = _dbfType == DbfType.Character;

            if (isChar)
            {
                _fieldLength += 256 * field.Decimals;
            }
            _decimals = isChar ? 0 : field.Decimals;
        }
예제 #3
0
        private object DecodeFloatPoint(byte[] data, DbfField field, DbfType type)
        {
            object ret = null;
            var    str = CharEncoding.GetString(data, 0, field.FieldLength);

            if (str.Length != 0)
            {
                var last = str[str.Length - 1];
                if (last != ' ' && last != '?')
                {
                    var culture = CultureInfo.InvariantCulture;
                    str = str.Replace(',', '.');
                    ret = type == DbfType.Double
                                                      ? (object)Double.Parse(str, Styles, culture)
                                                          : Decimal.Parse(str, Styles, culture);
                }
            }
            return(ret);
        }