Click here to Skip to main content
15,889,116 members
Articles / Web Development / HTML

Transformalizing NorthWind

Rate me:
Please Sign up or sign in to vote.
4.95/5 (29 votes)
24 Jul 2014GPL37 min read 57.7K   341   53  
Combining de-normalization, transformation, replication, and awesome-ness.
#region License
// /*
// See license included in this library folder.
// */
#endregion

using System;
using Transformalize.Libs.FileHelpers.ErrorHandling;
using Transformalize.Libs.FileHelpers.Fields;
using Transformalize.Libs.FileHelpers.Options;

namespace Transformalize.Libs.FileHelpers.Engines
{
    /// <summary>
    ///     Is a version of the <see cref="FileHelperEngine" /> exclusive for
    ///     fixed length records that allow you to change the delimiter an other options at runtime
    /// </summary>
    /// <remarks>
    ///     Useful when you need to export or import the same info with little different options.
    /// </remarks>
#if NET_2_0
    [DebuggerDisplay("FixedFileEngine for type: {RecordType.Name}. ErrorMode: {ErrorManager.ErrorMode.ToString()}. Encoding: {Encoding.EncodingName}")]
#endif
    public sealed class FixedFileEngine : FileHelperEngine
    {
        #region "  Constructor  "

        /// <summary>
        ///     Creates a version of the <see cref="FileHelperEngine" /> exclusive for
        ///     fixed length records that allow you to change the delimiter an other options at runtime
        /// </summary>
        /// <remarks>
        ///     Useful when you need to export or import the same info with little different options.
        /// </remarks>
        /// <param name="recordType">The record mapping class.</param>
        public FixedFileEngine(Type recordType)
            : base(recordType)
        {
            if (mRecordInfo.mFields[0] is FixedLengthField == false)
                throw new BadUsageException("The FixedFileEngine only accepts Record Types marked with FixedLengthRecord attribute");
        }

        #endregion

        /// <summary>Allow changes some fixed length options and others common settings.</summary>
        public new FixedRecordOptions Options
        {
            get { return (FixedRecordOptions) mOptions; }
        }
    }


#if NET_2_0

    /// <summary>
    /// Is a version of the <see cref="FileHelperEngine"/> exclusive for 
    /// fixed length records that allow you to change the delimiter an other options at runtime
    /// </summary>
    /// <remarks>
    /// Useful when you need to export or import the same info with little different options.
    /// </remarks>
#if NET_2_0
    [DebuggerDisplay("FixedFileEngine for type: {RecordType.Name}. ErrorMode: {ErrorManager.ErrorMode.ToString()}. Encoding: {Encoding.EncodingName}")]
#endif
    public sealed class FixedFileEngine<T> : FileHelperEngine<T>
	{
	#region "  Constructor  "

		/// <summary>
		/// Creates a version of the <see cref="FileHelperEngine"/> exclusive for 
		/// fixed length records that allow you to change the delimiter an other options at runtime
		/// </summary>
		/// <remarks>
		/// Useful when you need to export or import the same info with little different options.
		/// </remarks>
		public FixedFileEngine()
			: base()
		{
			if (mRecordInfo.mFields[0] is FixedLengthField  == false)
				throw new BadUsageException("The FixedFileEngine only accepts Record Types marked with FixedLengthRecord attribute");
		}

	#endregion

		
		/// <summary>Allow changes some fixed length options and others common settings.</summary>
		public new FixedRecordOptions Options
		{
            get { return (FixedRecordOptions) mOptions; }
		}
	}
#endif
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions