Пример #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.");
      * }*/
 }
Пример #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));
        }
Пример #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());
            }
        }
Пример #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));
        }
Пример #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();
            }
        }
Пример #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);
Пример #7
0
 /// <summary>
 /// When overloaded in a derived class, reads the next block.
 /// </summary>
 /// <returns></returns>
 protected abstract DataFileBlockBase OnReadNextBlock(DataFileBlockBase block);
Пример #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);
Пример #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();
     }
 }
Пример #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);
Пример #11
0
 protected override DataFileBlockBase OnReadNextBlock(DataFileBlockBase block)
 {
     return block ?? new SqlServerNativeDataFileBlock(this);
 }
Пример #12
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);
        }
Пример #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());
            }
        }
Пример #14
0
 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));
 }
Пример #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.");
     }
 }
Пример #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);
Пример #20
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);
        }
Пример #21
0
 private void CopyMembers(DataFileBlockBase old)
 {
     this.file = old.file;
     this.columns = new List<DataFileColumn>(old.columns);
 }
Пример #22
0
 public DataFileBlockBase(DataFileBlockBase old)
 {
     CopyMembers(old);
 }
Пример #23
0
 public DataFileBlockBase(DataFileBlockBase old)
 {
     CopyMembers(old);
 }
Пример #24
0
 protected override DataFileBlockBase OnWriteNextBlock(DataFileBlockBase block, System.Data.IDataReader dr)
 {
     return block ?? new SqlServerNativeDataFileBlock(this);
 }
Пример #25
0
 /// <summary>
 /// When overloaded in a derived class, reads the next block.
 /// </summary>
 /// <returns></returns>
 protected abstract DataFileBlockBase OnReadNextBlock(DataFileBlockBase block);