Exemple #1
0
 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.");
      * }*/
 }
Exemple #2
0
        /// <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));
        }
Exemple #3
0
        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());
            }
        }
Exemple #4
0
        /// <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);
Exemple #9
0
 /// <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();
     }
 }
Exemple #10
0
 /// <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));
 }
Exemple #18
0
 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.");
     }
 }
Exemple #19
0
 /// <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);
 }
Exemple #22
0
 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);
 }
Exemple #25
0
 /// <summary>
 /// When overloaded in a derived class, reads the next block.
 /// </summary>
 /// <returns></returns>
 protected abstract DataFileBlockBase OnReadNextBlock(DataFileBlockBase block);