Click here to Skip to main content
15,881,173 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.5K   341   53  
Combining de-normalization, transformation, replication, and awesome-ness.
#region License
// /*
// See license included in this library folder.
// */
#endregion

using Transformalize.Libs.FileHelpers.Attributes;
using Transformalize.Libs.FileHelpers.Core;
using Transformalize.Libs.FileHelpers.Enums;
using Transformalize.Libs.FileHelpers.Fields;

namespace Transformalize.Libs.FileHelpers.Options
{
    /// <summary>
    ///     This class allows you to set some options of the fixed length records but at runtime.
    ///     With this options the library is more flexible than never.
    /// </summary>
    public sealed class FixedRecordOptions : RecordOptions
    {
        internal FixedRecordOptions(RecordInfo info)
            : base(info)
        {
        }


        /// <summary>
        ///     Indicates the behavior when variable length records are found in a [<see cref="FixedLengthRecordAttribute" />]. (Note: nothing in common with [FieldOptional])
        /// </summary>
        public FixedMode FixedMode
        {
            get { return ((FixedLengthField) mRecordInfo.mFields[0]).mFixedMode; }
            set
            {
                for (var i = 0; i < mRecordInfo.mFieldCount; i++)
                {
                    ((FixedLengthField) mRecordInfo.mFields[i]).mFixedMode = value;
                }
            }
        }

#if NET_2_0
        [DebuggerDisplay("FileHelperEngine for type: {RecordType.Name}. ErrorMode: {ErrorManager.ErrorMode.ToString()}. Encoding: {Encoding.EncodingName}")]
#endif
        private int mRecordLength = int.MinValue;

        /// <summary>
        ///     The sum of the indivial field lengths.
        /// </summary>
        public int RecordLength
        {
            get
            {
                if (mRecordLength != int.MinValue)
                    return mRecordLength;

                mRecordLength = 0;
                foreach (FixedLengthField field in mRecordInfo.mFields)
                {
                    mRecordLength += field.mFieldLength;
                }

                return mRecordLength;
            }
        }
    }
}

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