Beispiel #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.");
      * }*/
 }
Beispiel #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));
        }
Beispiel #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());
            }
        }
Beispiel #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));
        }
Beispiel #5
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();
            }
        }
Beispiel #6
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);
Beispiel #7
0
 /// <summary>
 /// When overloaded in a derived class, reads the next block.
 /// </summary>
 /// <returns></returns>
 protected abstract DataFileBlockBase OnReadNextBlock(DataFileBlockBase block);
Beispiel #8
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);
Beispiel #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();
     }
 }
Beispiel #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);
        }
Beispiel #13
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());
            }
        }
 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));
 }
Beispiel #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.");
     }
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #25
0
 /// <summary>
 /// When overloaded in a derived class, reads the next block.
 /// </summary>
 /// <returns></returns>
 protected abstract DataFileBlockBase OnReadNextBlock(DataFileBlockBase block);