internal DbfTableParametersReadOnly(DbfTableParameters parameters) { encoding = parameters.encoding; openMemo = parameters.openMemo; strictHeader = parameters.strictHeader; tableType = parameters.tableType; memoType = parameters.memoType; indexType = parameters.indexType; memoTerminators = parameters.memoTerminators; openMode = parameters.openMode; }
public DbfTableParameters(DbfTableOpenMode?openmode = null, Encoding encoding = null, bool?openMemo = null, StrictHeader?strictHeader = null, DbfTableType?tableType = null, MemoFileType?memoType = null, IndexFileType?indexType = null) { _encoding = null; _openMemo = false; _strictHeader = 0; _tableType = 0; _memoType = 0; _indexType = 0; _memoTerminators = 0; _openMode = 0; // this.encoding = encoding; // null value mean "ReadDbfHeader_Encoding(_header.codepageCode)" will work this.openMemo = openMemo ?? defaultOpenMemo; this.strictHeader = strictHeader ?? defaultStrictHeader; this.tableType = tableType ?? defaultTableType; this.memoType = memoType ?? defaultMemoType; this.indexType = indexType ?? defaultIndexType; this.memoTerminators = defaultMemoTerminators; this.openMode = openmode ?? defaultOpenMode; }
/// <summary> /// Create a new DBF datafile. /// Create() can't overwrite exists file - it's a precautionary measure. /// </summary> /// <param name="path">A not exists filename.</param> /// <param name="columns">Definition of columns</param> /// <param name="codepageCode">Stored encoding information code, allways auto create appropriate encoding for open this file.</param> /// <returns></returns> public static DbfTable Create(string path, IEnumerable <ColumnDefinitionForCreateTable> columns, CodepageCodes codepageCode, DbfTableType tableType = DbfTableType.Undefined) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } if (columns == null) { throw new ArgumentNullException("columns"); } // var stream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); return(CreateHeader_DBF(stream, columns, tableType, codepageCode)); }
// /// <summary> /// Create a new DBF datafile. /// Create() can't overwrite exists file - it's a precautionary measure. /// </summary> /// <param name="path">A not exists filename.</param> /// <param name="columns">Definition of columns</param> /// <param name="encoding">Encoding for open created file. -- It mean too, CodepageCodes of new file will OEM</param> /// <returns></returns> public static DbfTable Create(string path, IEnumerable <ColumnDefinitionForCreateTable> columns, Encoding encoding, DbfTableType tableType = DbfTableType.Undefined) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } if (columns == null) { throw new ArgumentNullException("columns"); } // var streamDBF = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); DbfTable dbfTable = CreateHeader_DBF(streamDBF, columns, tableType, CodepageCodes.OEM, encoding); if (dbfTable.isExistsMemoField) { MemoFileType memoType = dbfTable.DefaultMemoFileFormatForDbf(); Stream streamMemo = CreateHeader_Memo(path, memoType); dbfTable.JoinMemoStream(streamMemo, memoType); } return(dbfTable); }
/// <summary> /// Opens a table from the specified stream. /// </summary> /// <param name="stream">The stream of dBASE table to open. The stream is closed when the returned table instance is disposed.</param> /// <returns>A table instance.</returns> /// <exception cref="ArgumentNullException"><paramref name="stream"/> is <c>null</c> or <paramref name="headerLoader"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException"><paramref name="stream"/> does not allow reading.</exception> /// <exception cref="NotSupportedException">The dBASE table constains one or more columns of unsupported type.</exception> public static DbfTable Open(Stream stream, Encoding encoding = null, bool openMemo = true, StrictHeader?strictHeader = null, DbfTableType tableType = DbfTableType.Undefined) { var parameters = new DbfTableParameters(encoding, openMemo, strictHeader, tableType, null, null); return(new DbfTable(stream, parameters)); }
public static DbfTable Open(string path, DbfTableOpenMode openMode, Encoding encoding = null, bool?openMemo = null, StrictHeader?strictHeader = null, DbfTableType tableType = DbfTableType.Undefined) { DbfTableParameters parameters = new DbfTableParameters(openMode, encoding, openMemo, strictHeader, tableType); return(Open(path, parameters)); }
public static DbfTableType GetTableTypeMainGroup(DbfTableType tableType) { return((DbfTableType)((int)tableType & 0x00FF)); }