protected override void OnBlockAppended(DataFileBlockBase block) { /* TODO: maybe remove * // Make sure only one block is added * if (Blocks.Count > 1) * { * throw new InvalidOperationException("Text files must consist of a single block."); * }*/ }
/// <summary> /// Initializes writing the next block. /// </summary> /// <param name="block"></param> /// <param name="dr"></param> /// <returns></returns> /// If next block protected override DataFileBlockBase OnWriteNextBlock(DataFileBlockBase block, IDataReader dr) { if (!isFirstBlock) { throw new InvalidOperationException(); // CSV files can contain a single file block only } return(block ?? new DelimitedTextDataFileBlock(this)); }
private void CopyMembers(DataFileBlockBase old) { this.file = old.file; // Deep copy columns this.columns = new List <Column>(); foreach (var c in old.columns) { this.columns.Add((Column)c.Clone()); } }
/// <summary> /// Advanced the file to the next block. /// </summary> /// <param name="block"></param> /// <returns></returns> protected override DataFileBlockBase OnReadNextBlock(DataFileBlockBase block) { // Only allow calling this function once if (!isFirstBlock) { return(null); } isFirstBlock = false; // Create a new block object, if necessary return(block ?? new DelimitedTextDataFileBlock(this)); }
/// <summary> /// Appends a new block to a file. /// </summary> /// <param name="block"></param> /// <remarks> /// File block are either created automatically during read, or appended /// manually before reading or when writing. /// </remarks> public void AppendBlock(DataFileBlockBase block) { switch (fileMode) { case DataFileMode.Read: // For read, blocks can be added to predefine columns, but otherwise // no need to do anything, just write them to the end of the list blocks.Add(block); OnBlockAppended(block); break; default: throw new NotImplementedException(); } }
/// <summary> /// When overriden in a derived class, writes the next file block. /// </summary> /// <param name="block"></param> /// <param name="dr"></param> /// <returns></returns> protected abstract DataFileBlockBase OnWriteNextBlock(DataFileBlockBase block, IDataReader dr);
/// <summary> /// When overloaded in a derived class, reads the next block. /// </summary> /// <returns></returns> protected abstract DataFileBlockBase OnReadNextBlock(DataFileBlockBase block);
/// <summary> /// Called by the library after a new block has been appended to the file. /// </summary> /// <param name="block"></param> protected abstract void OnBlockAppended(DataFileBlockBase block);
/// <summary> /// Appends a new block to a file. /// </summary> /// <param name="block"></param> /// <remarks> /// File block are either created automatically during read, or appended /// manually before reading or when writing. /// </remarks> public void AppendBlock(DataFileBlockBase block) { switch (fileMode) { case DataFileMode.Read: // For read, blocks can be added to predefine columns, but otherwise // no need to do anything, just write them to the end of the list blocks.Add(block); OnBlockAppended(block); break; default: throw new NotImplementedException(); } }
/// <summary> /// When overriden in a derived class, writes the next file block. /// </summary> /// <param name="block"></param> /// <param name="dr"></param> /// <returns></returns> protected abstract DataFileBlockBase OnWriteNextBlock(DataFileBlockBase block, IDataReader dr);
protected override DataFileBlockBase OnReadNextBlock(DataFileBlockBase block) { return block ?? new SqlServerNativeDataFileBlock(this); }
/// <summary> /// Initializes writing the next block. /// </summary> /// <param name="block"></param> /// <param name="dr"></param> /// <returns></returns> /// If next block protected override DataFileBlockBase OnWriteNextBlock(DataFileBlockBase block, IDataReader dr) { if (!isFirstBlock) { throw new InvalidOperationException(); // CSV files can contain a single file block only } return block ?? new DelimitedTextDataFileBlock(this); }
private void CopyMembers(DataFileBlockBase old) { this.file = old.file; // Deep copy columns this.columns = new List<Column>(); foreach (var c in old.columns) { this.columns.Add((Column)c.Clone()); } }
protected override void OnBlockAppended(DataFileBlockBase block) { // Do nothing }
protected override void OnBlockAppended(DataFileBlockBase block) { // Do nothing }
protected override DataFileBlockBase OnWriteNextBlock(DataFileBlockBase block, System.Data.IDataReader dr) { return(block ?? new SqlServerNativeDataFileBlock(this)); }
protected override DataFileBlockBase OnReadNextBlock(DataFileBlockBase block) { return(block ?? new SqlServerNativeDataFileBlock(this)); }
protected override void OnBlockAppended(DataFileBlockBase block) { // Make sure only one block is added if (Blocks.Count > 1) { throw new InvalidOperationException("Text files must consist of a single block."); } }
/// <summary> /// Called by the library after a new block has been appended to the file. /// </summary> /// <param name="block"></param> protected abstract void OnBlockAppended(DataFileBlockBase block);
/// <summary> /// Advanced the file to the next block. /// </summary> /// <param name="block"></param> /// <returns></returns> protected override DataFileBlockBase OnReadNextBlock(DataFileBlockBase block) { // Only allow calling this function once if (!isFirstBlock) { return null; } isFirstBlock = false; // Create a new block object, if necessary return block ?? new DelimitedTextDataFileBlock(this); }
private void CopyMembers(DataFileBlockBase old) { this.file = old.file; this.columns = new List<DataFileColumn>(old.columns); }
public DataFileBlockBase(DataFileBlockBase old) { CopyMembers(old); }
public DataFileBlockBase(DataFileBlockBase old) { CopyMembers(old); }
protected override DataFileBlockBase OnWriteNextBlock(DataFileBlockBase block, System.Data.IDataReader dr) { return block ?? new SqlServerNativeDataFileBlock(this); }
/// <summary> /// When overloaded in a derived class, reads the next block. /// </summary> /// <returns></returns> protected abstract DataFileBlockBase OnReadNextBlock(DataFileBlockBase block);