Click here to Skip to main content
15,884,986 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.6K   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.Enums;

namespace Transformalize.Libs.FileHelpers.Attributes
{
    /// <summary>
    ///     Indicates the <see cref="TrimMode" /> used after read to truncate the field.
    /// </summary>
    /// <remarks>
    ///     See the <a href="attributes.html">Complete Attributes List</a> for more clear info and examples of each one.
    /// </remarks>
    /// <seealso href="attributes.html">Attributes List</seealso>
    /// <seealso href="quick_start.html">Quick Start Guide</seealso>
    /// <seealso href="examples.html">Examples of Use</seealso>
    [AttributeUsage(AttributeTargets.Field)]
    public sealed class FieldTrimAttribute : Attribute
    {
        private static readonly char[] WhitespaceChars = new[]
                                                             {
                                                                 '\t', '\n', '\v', '\f', '\r', ' ', '\x00a0', '\u2000', '\u2001', '\u2002', '\u2003', '\u2004', '\u2005', '\u2006', '\u2007', '\u2008',
                                                                 '\u2009', '\u200a', '\u200b', '\u3000', '\ufeff'
                                                             };

        #region "  Constructors  "

        /// <summary>
        ///     Indicates the <see cref="TrimMode" /> used after read to truncate the field. By default trims the blank spaces and tabs.
        /// </summary>
        /// <param name="mode">
        ///     The <see cref="TrimMode" /> used after read.
        /// </param>
        public FieldTrimAttribute(TrimMode mode)
            : this(mode, WhitespaceChars)
        {
        }

        /// <summary>
        ///     Indicates the <see cref="TrimMode" /> used after read to truncate the field.
        /// </summary>
        /// <param name="mode">
        ///     The <see cref="TrimMode" /> used after read.
        /// </param>
        /// <param name="chars">A list of chars used to trim.</param>
        public FieldTrimAttribute(TrimMode mode, params char[] chars)
        {
            TrimMode = mode;
            Array.Sort(chars);
            TrimChars = chars;
        }

        /// <summary>
        ///     Indicates the <see cref="TrimMode" /> used after read to truncate the field.
        /// </summary>
        /// <param name="mode">
        ///     The <see cref="TrimMode" /> used after read.
        /// </param>
        /// <param name="trimChars">A string of chars used to trim.</param>
        public FieldTrimAttribute(TrimMode mode, string trimChars)
            : this(mode, trimChars.ToCharArray())
        {
        }

        #endregion

        internal Char[] TrimChars;
        internal TrimMode TrimMode;
    }
}

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