Ejemplo n.º 1
0
        protected bool leftSideDisplay_;                                                            // later it can be modified

        /// <summary>
        /// Initializes a new instance with the specified name, offset and size.
        /// </summary>
        /// <param name="name">The colum name.</param>
        /// <param name="offset">The column offset in a row in bytes.</param>
        /// <param name="size">The column size in bytes.</param>
        /// <param name="encoding">The encoding of column's content bytes.</param>
        /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is &lt; 1 or <paramref name="size"/> is &lt; 1.</exception>
        protected internal Column(string name, NativeColumnType dbfType, int offset, short size, short dec, Encoding encoding)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset");
            }

            if (size < 1)
            {
                throw new ArgumentOutOfRangeException("size");
            }

            this.name_     = name;
            this.dbfType_  = dbfType;
            this.offset_   = offset;
            this.size_     = size;
            this.dec_      = dec;
            this.encoding_ = encoding;

            displayWidth_    = size;                                                    // good for a few types of colums (for example string, bool)
            leftSideDisplay_ = true;

            switch (dbfType)
            {
            case NativeColumnType.Date:
                displayWidth_ = 10;                                                     // yyyy.mm.dd
                break;

            case NativeColumnType.Memo:
                displayWidth_ = 30;                                                     // only a value, maybe good
                break;

            case NativeColumnType.Float:
            case NativeColumnType.Numeric:
                //if (dec > 0)
                //{
                //  displayWidth_++;                                                            // for decimal dot
                //}
                leftSideDisplay_ = false;
                break;

            case NativeColumnType.Double:
                displayWidth_    = 18;
                leftSideDisplay_ = false;
                break;

            case NativeColumnType.Long:
                displayWidth_    = 11;                                                  // -2000000000
                leftSideDisplay_ = false;
                break;
            }
        }
Ejemplo n.º 2
0
        public static bool IsValidType(NativeColumnType dbfType, bool?dBase3column = null)
        {
            bool dbf3col = dBase3column ?? dBase3columnDefault;

            if (dbf3col)
            {
                if ((dbfType == NativeColumnType.Long) || (dbfType == NativeColumnType.Float))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        private ColumnDefinitionForCreateTable(string name, NativeColumnType dbfType, short size, short dec = 0, bool?dBase3column = null)
        {
            bool dbf3col = dBase3column ?? dBase3columnDefault;

            if (!IsValidName(name, onlyUppercaseNameValid, dbf3col))
            {
                throw new ArgumentOutOfRangeException("name", "Invalid name (character set, length, etc.) !");
            }

            if (size < 1)
            {
                throw new ArgumentOutOfRangeException("size");
            }

            if (!IsValidType(dbfType, dbf3col))
            {
                throw new ArgumentOutOfRangeException("name", "Invalid type for dBaseIII! [" + dbfType.ToString() + "]");
            }

            this.name_    = name;
            this.dbfType_ = dbfType;
            this.size_    = size;
            this.dec_     = dec;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance with the specified name and offset.
 /// </summary>
 /// <param name="name">The column name.</param>
 /// <param name="offset">The column offset in a row in bytes.</param>
 /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is &lt; 0.</exception>
 public DoubleColumn(string name, NativeColumnType dbfType, int offset)
     : base(name, dbfType, offset, 8, 0, null)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance with the specified name and offset.
 /// </summary>
 /// <param name="name">The column name.</param>
 /// <param name="offset">The column offset in a row in bytes.</param>
 /// <param name="size">The column size in bytes.</param>
 /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is &lt; 0 or <paramref name="size"/> is &lt; 0.</exception>
 public MemoColumn(string name, NativeColumnType dbfType, int offset, short size, short dec, Encoding encoding)
     : base(name, dbfType, offset, size, dec, encoding)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance with the specified name and offset.
 /// </summary>
 /// <param name="name">The column name.</param>
 /// <param name="offset">The column offset in a row in bytes.</param>
 /// <param name="size">The column size in bytes.</param>
 /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is &lt; 0 or <paramref name="size"/> is &lt; 0.</exception>
 public DecimalColumn(string name, NativeColumnType dbfType, int offset, short size, short dec)
     : base(name, dbfType, offset, size, dec, null)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance with the specified name and offset.
 /// </summary>
 /// <param name="name">The column name.</param>
 /// <param name="offset">The column offset in a row in bytes.</param>
 /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is &lt; 0.</exception>
 public Int32Column(string name, NativeColumnType dbfType, int offset)
     : base(name, dbfType, offset, 4, 0, null)
 {
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance with the specified name and offset.
 /// </summary>
 /// <param name="name">The column name.</param>
 /// <param name="offset">The column offset in a row in bytes.</param>
 /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c> or empty.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> is &lt; 0.</exception>
 public BooleanColumn(string name, NativeColumnType dbfType, int offset)
     : base(name, dbfType, offset, 1, 0, null)                                             // fix size: 1
 {
 }