text:
using EasyLOB.Library.Resources;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;

/*
    System.Boolean      bool
    System.Byte         byte
    System.SByte        sbyte
    System.Char         char
    System.DateTime     DateTime
    System.Decimal      decimal
    System.Double       double
    System.Single       float
    System.Guid         Guid
    System.Int16        short
    System.UInt16       ushort
    System.Int32        int
    System.UInt32       unit
    System.Int64        long
    System.UInt64       ulong
    System.Object       object
    System.String       string
    System.TimeSpan     TimeSpan
 */

namespace EasyLOB.Library
{
    #region Types

    public enum ZFileTypes
    {
        // Unknown
        ftUnknown = 0,

        // Document
        ftPDF = 11,
        ftDOC = 12,
        ftDOCX = 13,
        ftTXT = 14,
        ftXLS = 15,
        ftXLSX = 16,

        // Image
        ftJPG = 21,

        ftPNG = 22,

        // Audio
        ftMP3 = 31,

        // Video
        ftAVI = 41,

        ftMOV = 42,
        ftMP4 = 43,
        ftMPEG = 44,
        ftWMV = 45
    };

    #endregion Types

    /// <summary>
    /// ZLibrary Helper
    /// </summary>
    public static partial class LibraryHelper
    {
        #region Properties File

        public static Dictionary<ZFileTypes, string> FileAcronyms
        {
            get
            {
                Dictionary<ZFileTypes, string> result = new Dictionary<ZFileTypes, string>();
                foreach (KeyValuePair<ZFileTypes, string> pair in FileExtensions)
                {
                    result.Add(pair.Key, pair.Value.Replace(".", "")); // .pdf => pdf
                }
                return result;
            }
        }

        public static Dictionary<ZFileTypes, string> FileContentTypes
        {
            get
            {
                return new Dictionary<ZFileTypes, string>
                {
                    // Unknown
                    { ZFileTypes.ftUnknown, "" },
                    // Document
                    { ZFileTypes.ftPDF, "application/pdf" },
                    { ZFileTypes.ftDOC, "application/msword" },
                    { ZFileTypes.ftDOCX, "application/vnd.openxmlformats-officedocument.wordprocessingml.document" },
                    { ZFileTypes.ftTXT, "text/plain" },
                    { ZFileTypes.ftXLS, "application/vnd.ms-excel" },
                    { ZFileTypes.ftXLSX, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" },
                    // Image
                    { ZFileTypes.ftJPG, "image/jpeg" },
                    { ZFileTypes.ftPNG, "image/x-png" },
                    // Audio
                    { ZFileTypes.ftMP3, "audio/x-mp3" },
                    // Video
                    { ZFileTypes.ftAVI, "video/x-msvideo" },
                    { ZFileTypes.ftMOV, "video/quicktime" },
                    { ZFileTypes.ftMP4, "video/mp4" },
                    { ZFileTypes.ftMPEG, "video/mpeg" },
                    { ZFileTypes.ftWMV, "video/x-ms-wmv" }
                };
            }
        }

        public static Dictionary<ZFileTypes, string> FileExtensions
        {
            get
            {
                return new Dictionary<ZFileTypes, string>
                {
                    // Unknown
                    { ZFileTypes.ftUnknown, "" },
                    // Document
                    { ZFileTypes.ftPDF, ".pdf" },
                    { ZFileTypes.ftDOC, ".doc" },
                    { ZFileTypes.ftDOCX, ".docx" },
                    { ZFileTypes.ftTXT, ".txt" },
                    { ZFileTypes.ftXLS, ".xlsx" },
                    { ZFileTypes.ftXLSX, ".xlsx" },
                    // Image
                    { ZFileTypes.ftJPG, ".jpg" },
                    { ZFileTypes.ftPNG, ".png" },
                    // Audio
                    { ZFileTypes.ftMP3, ".mp3" },
                    // Video
                    { ZFileTypes.ftAVI, ".avi" },
                    { ZFileTypes.ftMOV, ".mov" },
                    { ZFileTypes.ftMP4, ".mp4" },
                    { ZFileTypes.ftMPEG, ".mpeg" },
                    { ZFileTypes.ftWMV, ".wmv" }
                };
            }
        }

        public static Dictionary<ZFileTypes, string> FileIcons
        {
            get
            {
                return new Dictionary<ZFileTypes, string>
                {
                    // Unknown
                    { ZFileTypes.ftUnknown, "" },
                    // Document
                    { ZFileTypes.ftPDF, "pdf.png" },
                    { ZFileTypes.ftDOC, "doc.png" },
                    { ZFileTypes.ftDOCX, "doc.png" },
                    { ZFileTypes.ftTXT, "txt.png" },
                    { ZFileTypes.ftXLS, "xls.png" },
                    { ZFileTypes.ftXLSX, "xls.png" },
                    // Image
                    { ZFileTypes.ftJPG, "image.png" },
                    { ZFileTypes.ftPNG, "image.png" },
                    // Audio
                    { ZFileTypes.ftMP3, "audio.png" },
                    // Video
                    { ZFileTypes.ftAVI, "movie.png" },
                    { ZFileTypes.ftMOV, "movie.png" },
                    { ZFileTypes.ftMP4, "movie.png" },
                    { ZFileTypes.ftMPEG, "movie.png" },
                    { ZFileTypes.ftWMV, "movie.png" }
                };
            }
        }

        #endregion Properties File

        #region Methods

        /// <summary>
        /// Get Regular Expression.
        /// </summary>
        /// <param name="type">Type</param>
        /// <returns>Regular Expression</returns>
        public static string GetRegularExpression(Type type)
        {
            string result = "";

            switch (GetTypeCode(type))
            {
                case TypeCode.DateTime:
                    result = PatternResources.RegularExpression_Date;
                    break;

                case TypeCode.Decimal:
                case TypeCode.Double:
                case TypeCode.Single:
                    result = PatternResources.RegularExpression_Float;
                    break;

                case TypeCode.Byte:
                case TypeCode.SByte:
                case TypeCode.Int16:
                case TypeCode.UInt16:
                case TypeCode.Int32:
                case TypeCode.UInt32:
                case TypeCode.Int64:
                case TypeCode.UInt64:
                    result = PatternResources.RegularExpression_Integer;
                    break;
            }

            return result;
        }

        /// <summary>
        /// Is another instance of the same application already running ?
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// Single Instance Application in C#
        /// http://www.codeproject.com/Articles/4430/Single-Instance-Application-in-C
        /// </remarks>
        public static bool IsApplicationAlreadyRunning()
        {
            string location = Assembly.GetExecutingAssembly().Location;
            FileSystemInfo fileInfo = new FileInfo(location);
            string exeFileName = fileInfo.Name;
            bool createdNew;

            Mutex mutex = new Mutex(true, "Global\\" + exeFileName, out createdNew);
            if (createdNew)
            {
                mutex.ReleaseMutex();
            }

            return !createdNew;
        }

        /// <summary>
        /// Is numeric ?
        /// </summary>
        /// <param name="o">Object</param>
        /// <returns>Is numeric ?</returns>
        public static bool IsNumeric(object o)
        {
            return (o == null) ? false : IsNumeric(o.GetType());
        }

        /// <summary>
        /// Is numeric ?
        /// </summary>
        /// <param name="type">Type</param>
        /// <returns>Is numeric ?</returns>
        public static bool IsNumeric(Type type)
        {
            if (type == null)
            {
                return false;
            }

            TypeCode typeCode = Type.GetTypeCode(type);

            switch (typeCode)
            {
                case TypeCode.Byte:
                case TypeCode.SByte:
                case TypeCode.Decimal:
                case TypeCode.Double:
                case TypeCode.Int16:
                case TypeCode.UInt16:
                case TypeCode.Int32:
                case TypeCode.UInt32:
                case TypeCode.Int64:
                case TypeCode.UInt64:
                case TypeCode.Single:
                    return true;
            }

            return false;
        }

        /// <summary>
        /// Convert string to typed object.
        /// </summary>
        /// <param name="value">Value</param>
        /// <param name="type">Type</param>
        /// <returns></returns>
        public static object StringToTypedObject(string value, Type type)
        {
            object result = (string)null;

            TypeCode typeCode = GetTypeCode(type);

            switch (typeCode)
            {
                case TypeCode.Boolean:
                    result = value.StringToBooleanNullable();
                    break;

                case TypeCode.Byte:
                    result = value.StringToByteNullable();
                    break;
                //case TypeCode.SByte:
                //    result = StringToSingleNullable(value);
                //    break;
                case TypeCode.Char:
                    result = value.StringToCharNullable();
                    break;

                case TypeCode.Decimal:
                    result = value.StringToDecimalNullable();
                    break;

                case TypeCode.Double:
                    result = value.StringToDoubleNullable();
                    break;

                case TypeCode.Single:
                    result = value.StringToSingleNullable();
                    break;

                case TypeCode.Int16:
                    result = value.StringToInt16Nullable();
                    break;
                //case TypeCode.UInt16:
                //    result = StringToUInt16Nullable();
                //    break;
                case TypeCode.Int32:
                    result = value.StringToInt32Nullable();
                    break;
                //case TypeCode.UInt32:
                //    result = StringToUInt32Nullable();
                //    break;
                case TypeCode.Int64:
                    result = value.StringToInt64Nullable();
                    break;
                //case TypeCode.UInt64:
                //    result = StringToUInt64Nullable();
                //    break;
                case TypeCode.Object:
                    switch (GetTypeName(type))
                    {
                        case "System.Guid":
                            result = value.StringToGuidNullable();
                            break;
                    }
                    break;

                case TypeCode.String:
                    result = value.StringToStringNullable();
                    break;
            }

            return result;
        }

        #endregion Methods

        #region Methods Array

        /// <summary>
        /// Convert array to nullable array.
        /// </summary>
        /// <typeparam name="T">Type.</typeparam>
        /// <param name="array">Array</param>
        /// <returns>Nullable array</returns>
        public static T?[] ArrayToNullableArray<T>(T[] array) where T : struct
        {
            T?[] nullableArray = new T?[array.Length];

            for (int i = 0; i < array.Length; i++)
                nullableArray[i] = array[i];

            return nullableArray;
        }

        //public static string ListToString(List<string> list)
        //{
        //    //string s = "";
        //    //foreach (string l in list)
        //    //{
        //    //    s += l + "\n";
        //    //}

        //    //return s;

        //    return String.Join("\n", list);
        //}

        /// <summary>
        /// Convert byte array (Binary) to string.
        /// </summary>
        /// <param name="value">Byte array (Binary)</param>
        /// <returns>String</returns>
        public static string BinaryToString(byte[] value)
        {
            ASCIIEncoding encoding = new ASCIIEncoding();

            return encoding.GetString(value);
        }

        //static byte[] GetByte(string str)
        //{
        //    byte[] bytes = new byte[str.Length * sizeof(char)];

        //    System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);

        //    return bytes;
        //}

        //static string GetString(byte[] bytes)
        //{
        //    char[] chars = new char[bytes.Length / sizeof(char)];

        //    System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length);

        //    return new string(chars);
        //}

        #endregion Methods Array

        #region Methods Boolean

        /// <summary>
        /// Is string Boolean true ?
        /// </summary>
        /// <param name="value">String</param>
        /// <returns>Is true ?</returns>
        public static bool BooleanIsTrue(string value)
        {
            bool result = false;

            try { result = (value.ToUpper() == Boolean.TrueString.ToUpper()); }
            catch { }

            return result;
        }

        /// <summary>
        /// Is string Boolean false ?
        /// </summary>
        /// <param name="value">String</param>
        /// <returns>Is false ?</returns>
        public static bool BooleanIsFalse(string value)
        {
            bool result = false;

            try { result = value.ToUpper() == Boolean.FalseString.ToUpper(); }
            catch { }

            return result;
        }

        /// <summary>
        /// Convert Boolean to String.
        /// </summary>
        /// <param name="value">Boolean value</param>
        /// <returns>String value</returns>
        public static string BooleanToString(bool value)
        {
            string result = "";

            try
            {
                result = value ? Boolean.TrueString : Boolean.FalseString;
            }
            catch { }

            return result;
        }

        /// <summary>
        /// Convert nullable Boolean to String.
        /// </summary>
        /// <param name="value">Nullable Boolean value</param>
        /// <returns>String value</returns>
        public static bool DataToBoolean(bool? value)
        {
            if (!value.HasValue)
            {
                return false;
            }
            else
            {
                return (bool)value;
            }
        }

        /// <summary>
        /// Convert Boolean to Boolean.
        /// </summary>
        /// <param name="value">Boolean value</param>
        /// <returns>Boolean value</returns>
        public static Boolean BooleanToBoolean(bool value)
        {
            return value;
        }

        /// <summary>
        /// Convert Boolean to nullable Boolean.
        /// </summary>
        /// <param name="value">Boolean value</param>
        /// <returns>Boolean value</returns>
        public static Boolean? BooleanToBooleanNullable(bool value)
        {
            return (Boolean?)value;
        }

        #endregion Methods Boolean

        #region Methods ConfigurationManager

        public static T AppSettings<T>(string name)
        {
            var appSetting = ConfigurationManager.AppSettings[name];
            if (appSetting == null)
            {
                throw new Exception(String.Format("AppSettings[\"{0}\"] = \"?\"", name));
            }

            var converter = TypeDescriptor.GetConverter(typeof(T));

            return (T)(converter.ConvertFromInvariantString(appSetting));
        }

        public static string ConnectionStrings(string connectionName)
        {
            string connectionString = ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
            if (connectionString == null)
            {
                throw new Exception(String.Format("ConnectionStrings[\"{0}\"] = \"?\"", connectionString));
            }

            return connectionString;
        }

        #endregion Methods ConfigurationManager

        #region Methods DataToObject

        /// <summary>
        /// Convert Boolean to Object.
        /// </summary>
        /// <param name="value">Boolean value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(bool? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            };
        }

        /// <summary>
        /// Convert Binary to Object.
        /// </summary>
        /// <param name="value">Byte array (Binary) value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(byte[] value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert Byte to Object.
        /// </summary>
        /// <param name="value">Byte value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(byte? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert SByte to Object.
        /// </summary>
        /// <param name="value">Sbyte value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(sbyte? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert Char to Object.
        /// </summary>
        /// <param name="value">Char value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(char? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert DateTime to Object.
        /// </summary>
        /// <param name="value">DateTime value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(DateTime? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert Decimal to Object.
        /// </summary>
        /// <param name="value">Decimal value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(decimal? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert Double to Object.
        /// </summary>
        /// <param name="value">Double value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(double? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert Guid to Object.
        /// </summary>
        /// <param name="value">Guid value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(Guid? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert Int32 to Object.
        /// </summary>
        /// <param name="value">Int32 value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(int? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert UInt32 to Object.
        /// </summary>
        /// <param name="value">UInt32 value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(uint? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert Int64 to Object.
        /// </summary>
        /// <param name="value">Int64 value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(long? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert UInt64 to Object.
        /// </summary>
        /// <param name="value">UInt64 value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(ulong? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert Int16 to Object.
        /// </summary>
        /// <param name="value">Int16 value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(short? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert UInt16 to Object.
        /// </summary>
        /// <param name="value">UInt16 value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(ushort? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert Object to Object.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(object value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert Single to Object.
        /// </summary>
        /// <param name="value">Single value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(float? value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        /// <summary>
        /// Convert String to Object.
        /// </summary>
        /// <param name="value">String value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(string value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value.Trim();
            }
        }

        /// <summary>
        /// Convert TimeSpan to Object.
        /// </summary>
        /// <param name="value">TimeSpan value</param>
        /// <returns>Object value</returns>
        public static object DataToObject(TimeSpan value)
        {
            if (value == null)
            {
                return DBNull.Value;
            }
            else
            {
                return value;
            }
        }

        #endregion Methods DataToObject

        #region Methods DataToString

        // Boolean

        /// <summary>
        /// Convert Boolean to String.
        /// </summary>
        /// <param name="value">Boolean value</param>
        /// <returns>String value</returns>
        public static string DataToString(bool? value)
        {
            if (!value.HasValue)
            {
                return "";
            }
            else
            {
                return ((bool)value ? Boolean.TrueString : Boolean.FalseString);
            }
        }

        // Binary

        /// <summary>
        /// Convert Binary to String.
        /// </summary>
        /// <param name="value">Byte array (Binary) value</param>
        /// <returns>String value</returns>
        public static string DataToString(byte[] value)
        {
            if (value == null || value.Length == 0)
            {
                return "";
            }
            else
            {
                byte[] valueNotNullable = new byte[value.Length];

                for (int i = 0; i < value.Length; i++)
                    valueNotNullable[i] = (byte)value[i];

                return (BinaryToString(valueNotNullable));
            }
        }

        // Byte

        /// <summary>
        /// Convert Byte to String.
        /// </summary>
        /// <param name="value">Byte value</param>
        /// <returns>String value</returns>
        public static string DataToString(byte? value)
        {
            return DataToString(value, PatternResources.Format_String);
        }

        /// <summary>
        /// Convert Byte to String.
        /// </summary>
        /// <param name="value">Byte value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(byte? value, string format)
        {
            if (!value.HasValue)
            {
                return "";
            }
            else
            {
                return ((byte)value).ToString(format);
            }
        }

        // SByte

        /// <summary>
        /// Convert SByte to String.
        /// </summary>
        /// <param name="value">SByte value</param>
        /// <returns>String value</returns>
        public static string DataToString(sbyte? value)
        {
            return DataToString(value, PatternResources.Format_String);
        }

        /// <summary>
        /// Convert SByte to String.
        /// </summary>
        /// <param name="value">SByte value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(sbyte? value, string format)
        {
            if (!value.HasValue)
            {
                return "";
            }
            else
            {
                return ((sbyte)value).ToString(format);
            }
        }

        // DateTime

        /// <summary>
        /// Convert DateTime to String.
        /// </summary>
        /// <param name="value">DateTime value</param>
        /// <returns>String value</returns>
        public static string DataToString(DateTime? value)
        {
            return DataToString(value, PatternResources.Format_Date);
        }

        /// <summary>
        /// Convert DateTime to String.
        /// </summary>
        /// <param name="value">DateTime value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(DateTime? value, string format)
        {
            if (!value.HasValue)
            {
                return "";
            }
            else
            {
                return ((DateTime)value).ToString(format);
            }
        }

        // Decimal

        /// <summary>
        /// Convert Decimal to String.
        /// </summary>
        /// <param name="value">Decimal value</param>
        /// <returns>String value</returns>
        public static string DataToString(decimal? value)
        {
            return DataToString(value, PatternResources.Format_Float);
        }

        /// <summary>
        /// Convert Decimal to String.
        /// </summary>
        /// <param name="value">Decimal value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(decimal? value, string format)
        {
            if (!value.HasValue)
            {
                return "";
            }
            else
            {
                return ((decimal)value).ToString(format);
            }
        }

        // Double

        /// <summary>
        /// Convert Double to String.
        /// </summary>
        /// <param name="value">Double value</param>
        /// <returns>String value</returns>
        public static string DataToString(double? value)
        {
            return DataToString(value, PatternResources.Format_Float);
        }

        /// <summary>
        /// Convert Double to String.
        /// </summary>
        /// <param name="value">Double value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(double? value, string format)
        {
            if (!value.HasValue)
            {
                return "";
            }
            else
            {
                return ((double)value).ToString(format);
            }
        }

        // Guid

        /// <summary>
        /// Convert Guid to String.
        /// </summary>
        /// <param name="value">Guid value</param>
        /// <returns>String value</returns>
        public static string DataToString(Guid? value)
        {
            if (!value.HasValue)
                return "";
            else
                return ((Guid)value).ToString();
        }

        // Int16

        /// <summary>
        /// Convert Int16 to String.
        /// </summary>
        /// <param name="value">Int16 value</param>
        /// <returns>String value</returns>
        public static string DataToString(short? value)
        {
            return DataToString(value, PatternResources.Format_Integer);
        }

        /// <summary>
        /// Convert Int16 to String.
        /// </summary>
        /// <param name="value">Int16 value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(short? value, string format)
        {
            if (!value.HasValue)
                return "";
            else
                return ((int)value).ToString(format);
        }

        // UInt16

        /// <summary>
        /// Convert UInt16 to String.
        /// </summary>
        /// <param name="value">UInt16 value</param>
        /// <returns>String value</returns>
        public static string DataToString(ushort? value)
        {
            return DataToString(value, PatternResources.Format_Integer);
        }

        /// <summary>
        /// Convert UInt16 to String.
        /// </summary>
        /// <param name="value">UInt16 value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(ushort? value, string format)
        {
            if (!value.HasValue)
                return "";
            else
                return ((uint)value).ToString(format);
        }

        // Int32

        /// <summary>
        /// Convert Int32 to String.
        /// </summary>
        /// <param name="value">Int32 value</param>
        /// <returns>String value</returns>
        public static string DataToString(int? value)
        {
            return DataToString(value, PatternResources.Format_Integer);
        }

        /// <summary>
        /// Convert Int32 to String.
        /// </summary>
        /// <param name="value">Int32 value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(int? value, string format)
        {
            if (!value.HasValue)
                return "";
            else
                return ((int)value).ToString(format);
        }

        // UInt32

        /// <summary>
        /// Convert UInt32 to String.
        /// </summary>
        /// <param name="value">UInt32 value</param>
        /// <returns>String value</returns>
        public static string DataToString(uint? value)
        {
            return DataToString(value, PatternResources.Format_Integer);
        }

        /// <summary>
        /// Convert UInt32 to String.
        /// </summary>
        /// <param name="value">UInt32 value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(uint? value, string format)
        {
            if (!value.HasValue)
                return "";
            else
                return ((uint)value).ToString(format);
        }

        // Int64

        /// <summary>
        /// Convert Int64 to String.
        /// </summary>
        /// <param name="value">Int64 value</param>
        /// <returns>String value</returns>
        public static string DataToString(long? value)
        {
            return DataToString(value, PatternResources.Format_Integer);
        }

        /// <summary>
        /// Convert Int64 to String.
        /// </summary>
        /// <param name="value">Int64 value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(long? value, string format)
        {
            if (!value.HasValue)
                return "";
            else
                return ((long)value).ToString(format);
        }

        // UInt64

        /// <summary>
        /// Convert UInt64 to String.
        /// </summary>
        /// <param name="value">UInt64 value</param>
        /// <returns>String value</returns>
        public static string DataToString(ulong? value)
        {
            return DataToString(value, PatternResources.Format_Integer);
        }

        /// <summary>
        /// Convert UInt64 to String.
        /// </summary>
        /// <param name="value">UInt64 value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(ulong? value, string format)
        {
            if (!value.HasValue)
                return "";
            else
                return ((ulong)value).ToString(format);
        }

        // Single

        /// <summary>
        /// Convert Single to String.
        /// </summary>
        /// <param name="value">Single value</param>
        /// <returns>String value</returns>
        public static string DataToString(float? value)
        {
            return DataToString(value, PatternResources.Format_Float);
        }

        /// <summary>
        /// Convert Single to String.
        /// </summary>
        /// <param name="value">Single value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(float? value, string format)
        {
            if (!value.HasValue)
            {
                return "";
            }
            else
            {
                return ((float)value).ToString(format);
            }
        }

        // String

        /// <summary>
        /// Convert String to String.
        /// </summary>
        /// <param name="value">String value</param>
        /// <returns>String value</returns>
        public static string DataToString(string value)
        {
            return DataToString(value, PatternResources.Format_String);
        }

        /// <summary>
        /// Convert String to String.
        /// </summary>
        /// <param name="value">String value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(string value, string format) // DbType.XML
        {
            if (String.IsNullOrEmpty(value))
            {
                return "";
            }
            else
            {
                return value;
            }
        }

        // TimeSpan

        /// <summary>
        /// Convert TimeSpan to String.
        /// </summary>
        /// <param name="value">TimeSpan value</param>
        /// <returns>String value</returns>
        public static string DataToString(TimeSpan? value)
        {
            return DataToString(value, PatternResources.Format_String);
        }

        /// <summary>
        /// Convert TimeSpan to String.
        /// </summary>
        /// <param name="value">TimeSpan value</param>
        /// <param name="format">Format</param>
        /// <returns>String value</returns>
        public static string DataToString(TimeSpan? value, string format)
        {
            if (!value.HasValue)
            {
                return "";
            }
            else
            {
                return ((TimeSpan)value).ToString(format);
            }
        }

        #endregion Methods DataToString

        #region Methods File

        /// <summary>
        /// Get acronym.
        /// </summary>
        /// <param name="fileType">File type</param>
        /// <returns>Acronym</returns>
        public static string GetAcronym(ZFileTypes fileType)
        {
            string acronym;

            if (!LibraryHelper.FileAcronyms.TryGetValue(fileType, out acronym))
            {
                LibraryHelper.FileContentTypes.TryGetValue(ZFileTypes.ftUnknown, out acronym);
            }

            return acronym;
        }

        /// <summary>
        /// Get content type.
        /// </summary>
        /// <param name="fileType">File type</param>
        /// <returns>Content type</returns>
        public static string GetContentType(ZFileTypes fileType)
        {
            string contentType;

            if (!LibraryHelper.FileContentTypes.TryGetValue(fileType, out contentType))
            {
                LibraryHelper.FileContentTypes.TryGetValue(ZFileTypes.ftUnknown, out contentType);
            }

            return contentType;
        }

        /// <summary>
        /// Get file extension.
        /// </summary>
        /// <param name="fileType">File type</param>
        /// <returns>File extension</returns>
        public static string GetFileExtension(ZFileTypes fileType)
        {
            string extension;

            if (!LibraryHelper.FileExtensions.TryGetValue(fileType, out extension))
            {
                LibraryHelper.FileExtensions.TryGetValue(ZFileTypes.ftUnknown, out extension);
            }

            return extension;
        }

        /// <summary>
        /// Get file type.
        /// </summary>
        /// <param name="acronymOrExtension">File acronym (pdf) or extension (.pdf)</param>
        /// <returns>File type</returns>
        public static ZFileTypes GetFileType(string acronymOrExtension)
        {
            ZFileTypes fileType = ZFileTypes.ftUnknown;

            // Acronyms

            foreach (KeyValuePair<ZFileTypes, string> pair in LibraryHelper.FileAcronyms)
            {
                if (pair.Value == acronymOrExtension)
                {
                    fileType = pair.Key;
                    break;
                }
            }

            // Extensions

            if (fileType == (int)ZFileTypes.ftUnknown)
            {
                foreach (KeyValuePair<ZFileTypes, string> pair in LibraryHelper.FileExtensions)
                {
                    if (pair.Value == acronymOrExtension)
                    {
                        fileType = pair.Key;
                        break;
                    }
                }
            }

            return fileType;
        }

        /// <summary>
        /// Get icon.
        /// </summary>
        /// <param name="fileType">File type</param>
        /// <returns>Icon file name</returns>
        public static string GetIcon(ZFileTypes fileType)
        {
            string icon = "";

            if (!LibraryHelper.FileIcons.TryGetValue(fileType, out icon))
            {
                LibraryHelper.FileIcons.TryGetValue(ZFileTypes.ftUnknown, out icon);
            }

            return icon;
        }

        /// <summary>
        /// Get icon.
        /// </summary>
        /// <param name="acronymOrExtension">File acronym (pdf) or extension (.pdf)</param>
        /// <returns>Icon file name</returns>
        public static string GetIcon(string acronymOrExtension)
        {
            string icon = "";

            if (!LibraryHelper.FileIcons.TryGetValue(GetFileType(acronymOrExtension), out icon))
            {
                LibraryHelper.FileIcons.TryGetValue(ZFileTypes.ftUnknown, out icon);
            }

            return icon;
        }

        #endregion Methods File

        #region Methods IO

        /// <summary>
        /// Add directory separator, if necessary.
        /// </summary>
        /// <param name="path">Path</param>
        /// <returns></returns>
        public static string AddDirectorySeparator(string path)
        {
            // Path.AltDirectorySeparatorChar = /
            // Path.DirectorySeparatorChar = \
            // Path.PathSeparator = ;
            // Path.VolumeSeparatorChar = :

            if (!String.IsNullOrEmpty(path))
            {
                string separator = Path.DirectorySeparatorChar.ToString();
                string altSeparator = Path.AltDirectorySeparatorChar.ToString();

                path = path.Trim();

                if (path.EndsWith(separator) || path.EndsWith(altSeparator))
                {
                    return path;
                }

                if (path.Contains(separator)) // [\]
                {
                    return path + separator;
                }

                if (!String.IsNullOrEmpty(path)) // [/]
                {
                    return path + altSeparator;
                }

                //if (path.Contains(altSeparator))
                //{
                //    return path + altSeparator;
                //}

                //if (!String.IsNullOrEmpty(path))
                //{
                //    return path + separator;
                //}
            }

            return path;
        }

        #endregion Methods IO

        #region Methods Message

        public static string MessageNotFound(string entity)
        {
            return entity + " " + ErrorResources.NotFound;
        }

        public static string MessageNotFound(string entity, object[] ids)
        {
            string result = "";

            foreach(object id in ids)
            {
                result = (String.IsNullOrEmpty(result) ? "" : ", ") + id.ToString();
            }

            result = entity + " [" + result + "] " + ErrorResources.NotFound;

            return result;
        }

        #endregion Methods Message

        #region Methods ObjectTo... | ObjectTo...Nullable

        // Binary

        /// <summary>
        /// Convert Object to Byte[] (Binary).
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Byte[] (Binary) value</returns>
        public static byte[] ObjectToBinary(object value)
        {
            try
            {
                return (byte[])value;
            }
            catch
            {
                return new byte[] { };
            }
        }

        /// <summary>
        /// Convert Object to nullable Byte[] (Binary).
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable Byte[] (Binary) value</returns>
        public static byte[] ObjectToBinaryNullable(object value)
        {
            try
            {
                return (byte[])value;
            }
            catch
            {
                return null;
            }
        }

        // Boolean

        /// <summary>
        /// Convert Object to Boolean.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Boolean value</returns>
        public static bool ObjectToBoolean(object value)
        {
            if (value == null)
            {
                return LibraryDefaults.Default_Boolean;
            }
            else
            {
                return (bool)value;
            }
        }

        /// <summary>
        /// Convert Object to nullable Boolean.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable Boolean value</returns>
        public static bool? ObjectToBooleanNullable(object value)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                return (bool?)value;
            }
        }

        // Byte

        /// <summary>
        /// Convert Object to Byte.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Byte value</returns>
        public static byte ObjectToByte(object value)
        {
            if (value == null)
            {
                return LibraryDefaults.Default_Byte;
            }
            else
            {
                return (byte)value;
            }
        }

        /// <summary>
        /// Convert Object to nullable Byte.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nulllable Byte value</returns>
        public static byte? ObjectToByteNullable(object value)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                return (byte?)value;
            }
        }

        // Char

        /// <summary>
        /// Convert Object to Char.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Char value</returns>
        public static char ObjectToChar(object value)
        {
            if (value == null)
            {
                return LibraryDefaults.Default_Char;
            }
            else
            {
                return (char)value;
            }
        }

        /// <summary>
        /// Convert Object to nullable Char.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable Char value</returns>
        public static char? ObjectToCharNullable(object value)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                return (char?)value;
            }
        }

        // DateTime

        /// <summary>
        /// Convert Object to DateTime.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>DateTime value</returns>
        public static DateTime ObjectToDateTime(object value)
        {
            try
            {
                return (DateTime)value;
            }
            catch
            {
                return LibraryDefaults.Default_DateTime;
            }
        }

        /// <summary>
        /// Convert Object to nullable DateTime.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable DateTime value</returns>
        public static DateTime? ObjectToDateTimeNullable(object value)
        {
            try
            {
                return (DateTime)value;
            }
            catch
            {
                return null;
            }
        }

        // Decimal

        /// <summary>
        /// Convert Object to Decimal.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Decimal value</returns>
        public static decimal ObjectToDecimal(object value)
        {
            if (value == null)
            {
                return LibraryDefaults.Default_Decimal;
            }
            else
            {
                return (decimal)value;
            }
        }

        /// <summary>
        /// Convert Object to nullable Decimal.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable Decimal value</returns>
        public static decimal? ObjectToDecimalNullable(object value)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                return (decimal?)value;
            }
        }

        // Double

        /// <summary>
        /// Convert Object to Double.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Double value</returns>
        public static double ObjectToDouble(object value)
        {
            if (value == null)
            {
                return LibraryDefaults.Default_Double;
            }
            else
            {
                return (double)value;
            }
        }

        /// <summary>
        /// Convert Object to nullable Double.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable Double value</returns>
        public static double? ObjectToDoubleNullable(object value)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                return (double?)value;
            }
        }

        // Guid

        /// <summary>
        /// Convert Object to Guid.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Guid value</returns>
        public static Guid? ObjectToGuid(object value)
        {
            return ObjectToGuidNullable(value);
        }

        /// <summary>
        /// Convert Object to nullable Guid.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable Guid value</returns>
        public static Guid? ObjectToGuidNullable(object value)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                return (Guid?)value;
            }
        }

        // Int16

        /// <summary>
        /// Convert Object to Int16.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Int16 value</returns>
        public static short ObjectToInt16(object value)
        {
            if (value == null)
            {
                return LibraryDefaults.Default_Int16;
            }
            else
            {
                return (short)value;
            }
        }

        /// <summary>
        /// Convert Object to nullable Int16.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable Int16 value</returns>
        public static short? ObjectToInt16Nullable(object value)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                return (short?)value;
            }
        }

        // Int32

        /// <summary>
        /// Convert Object to Int32.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Int32 value</returns>
        public static int ObjectToInt32(object value)
        {
            if (value == null)
            {
                return LibraryDefaults.Default_Int32;
            }
            else
            {
                return (int)value;
            }
        }

        /// <summary>
        /// Convert Object to nullable Int32.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable Int32 value</returns>
        public static int? ObjectToInt32Nullable(object value)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                return (int?)value;
            }
        }

        // Int64

        /// <summary>
        /// Convert Object to Int64.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Int64 value</returns>
        public static long ObjectToInt64(object value)
        {
            if (value == null)
            {
                return LibraryDefaults.Default_Int64;
            }
            else
            {
                return (long)value;
            }
        }

        /// <summary>
        /// Convert Object to nullable Int64.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable Int64 value</returns>
        public static long? ObjectToInt64Nullable(object value)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                return (long?)value;
            }
        }

        // Object

        /// <summary>
        /// Convert Object to Object.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Object value</returns>
        public static object ObjectToObject(object value)
        {
            return ObjectToObjectNullable(value);
        }

        /// <summary>
        /// Convert Object to nullable Object.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable Object value</returns>
        public static object ObjectToObjectNullable(object value)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                return value;
            }
        }

        // Single

        /// <summary>
        /// Convert Object to Single.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Single value</returns>
        public static float ObjectToSingle(object value)
        {
            if (value == null)
            {
                return LibraryDefaults.Default_Single;
            }
            else
            {
                return (float)value;
            }
        }

        /// <summary>
        /// Convert Object to nullable Single.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable Single value</returns>
        public static float? ObjectToSingleNullable(object value)
        {
            if (value == null)
            {
                return null;
            }
            else
            {
                return (float?)value;
            }
        }

        // String

        /// <summary>
        /// Convert Object to String.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>String value</returns>
        public static string ObjectToString(object value)
        {
            try
            {
                return (string)value;
            }
            catch
            {
                return LibraryDefaults.Default_String;
            }
        }

        /// <summary>
        /// Convert Object to nullable String.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable String value</returns>
        public static string ObjectToStringNullable(object value)
        {
            try
            {
                return (string)value;
            }
            catch
            {
                return null;
            }
        }

        // TimeSpan

        /// <summary>
        /// Convert Object to TimeSpan.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>TimeSpan value</returns>
        public static TimeSpan ObjectToTimeSpan(object value)
        {
            try
            {
                return (TimeSpan)value;
            }
            catch
            {
                return new TimeSpan();
            }
        }

        /// <summary>
        /// Convert Object to nullable TimeSpan.
        /// </summary>
        /// <param name="value">Object value</param>
        /// <returns>Nullable TimeSpane value</returns>
        public static TimeSpan? ObjectToTimeSpanNullable(object value)
        {
            try
            {
                return (TimeSpan)value;
            }
            catch
            {
                return null;
            }
        }

        #endregion Methods ObjectTo... | ObjectTo...Nullable

        #region Methods Reflection

        private readonly static object _lock = new object();

        public static T Clone<T>(T from)
        {
            return Clone<T>(from, null);
        }

        public static T Clone<T>(T from, List<string> excludedProperties)
        {
            T to = Activator.CreateInstance<T>();

            Clone<T>(from, to, excludedProperties);

            return to;
        }

        public static void Clone<T>(T from, T to)
        {
            Clone(from, to, null);
        }

        public static void Clone<T>(T from, T to, List<string> excludedProperties)
        {
            if (from != null && to != null)
            {
                try
                {
                    Monitor.Enter(_lock);
                    PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                    foreach (PropertyInfo property in properties)
                    {
                        if (excludedProperties == null || !excludedProperties.Contains(property.Name))
                        {
                            if (property.GetValue(to, null) != property.GetValue(from, null))
                            {
                                if (property.PropertyType == typeof(String))
                                {
                                    string value = (property.GetValue(from, null) as string).Trim();
                                    property.SetValue(to, value, null);
                                }
                                else
                                {
                                    property.SetValue(to, property.GetValue(from, null), null);
                                }
                            }
                        }
                    }
                }
                finally
                {
                    Monitor.Exit(_lock);
                }
            }
        }

        /// <summary>
        /// Create instance.
        /// </summary>
        /// <param name="type">Instance Type</param>
        /// <returns>Instance</returns>
        public static object CreateInstance(Type type)
        {
            return Activator.CreateInstance(type);
        }

        /// <summary>
        /// Create instance.
        /// </summary>
        /// <param name="type">Instance Type</param>
        /// <param name="args">Arguments</param>
        /// <returns>Instance</returns>
        public static object CreateInstance(Type type, object[] args)
        {
            return Activator.CreateInstance(type, args);
        }

        /// <summary>
        /// Invoke static method.
        /// </summary>
        /// <param name="type">Type</param>
        /// <param name="methodName">Method name</param>
        /// <param name="args">Parameters</param>
        /// <returns>Method result</returns>
        public static object InvokeMethod(Type type, string methodName, object[] args)
        {
            const BindingFlags bindingFlags = BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
            MethodInfo method = type.GetMethod(methodName, bindingFlags);

            return method.Invoke(null, args);
        }

        /// <summary>
        /// Invoke instance method.
        /// </summary>
        /// <param name="instance">Instance</param>
        /// <param name="methodName">Method name</param>
        /// <param name="args">Parameters</param>
        /// <returns>Method result</returns>
        public static object InvokeMethod(object instance, string methodName, object[] args)
        {
            Type type = instance.GetType();
            const BindingFlags bindingFlags = BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
            MethodInfo method = type.GetMethod(methodName, bindingFlags);

            return method.Invoke(instance, args);
        }

        // Type

        /// <summary>
        /// Get Class Type.
        /// </summary>
        /// <param name="className">Class name</param>
        /// <returns>Type</returns>
        public static Type GetType(string className)
        {
            Type type = Type.GetType(className); // Class Library

            if (type == null)
            {
                Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
                foreach (var assembly in assemblies) // Class Library
                {
                    type = assembly.GetType(className);
                    if (type != null)
                    {
                        break;
                    }
                }
            }

            //if (type == null)
            //{
            //    type = Type.GetType(className + ", App_Code"); // App_Code
            //}

            return type;
        }

        /// <summary>
        /// Get Property Type.
        /// </summary>
        /// <param name="className">Class name</param>
        /// <param name="propertyName">Property name</param>
        /// <returns></returns>
        public static Type GetType(string className, string propertyName)
        {
            return GetType(GetType(className), propertyName);
        }

        /// <summary>
        /// Get Property Type.
        /// </summary>
        /// <param name="type">Type</param>
        /// <param name="propertyName">Property name</param>
        /// <returns>Type</returns>
        public static Type GetType(Type type, string propertyName)
        {
            try
            {
                PropertyInfo p = type.GetProperty(propertyName);
                type = p.PropertyType;
            }
            catch
            {
                type = null;
            }

            return type;
        }

        /// <summary>
        /// Get Type Code.
        /// </summary>
        /// <param name="className">Class name</param>
        /// <returns></returns>
        public static TypeCode GetTypeCode(string className)
        {
            return Type.GetTypeCode(GetType(className));
        }

        /// <summary>
        /// Get Type Code.
        /// </summary>
        /// <param name="type">Type</param>
        /// <returns></returns>
        public static TypeCode GetTypeCode(Type type)
        {
            return Type.GetTypeCode(type);
        }

        /// <summary>
        /// Get Type Code.
        /// </summary>
        /// <param name="className">Class name</param>
        /// <param name="propertyName">Property name</param>
        /// <returns></returns>
        public static TypeCode GetTypeCode(string className, string propertyName)
        {
            TypeCode typeCode = TypeCode.String;

            try
            {
                Type propertyType = GetType(className, propertyName);
                typeCode = GetTypeCode(propertyType);
            }
            catch { }

            return typeCode;
        }

        /// <summary>
        /// Get Type Code.
        /// </summary>
        /// <param name="type">Type</param>
        /// <param name="propertyName">Property name</param>
        /// <returns></returns>
        public static TypeCode GetTypeCode(Type type, string propertyName)
        {
            TypeCode typeCode = TypeCode.String;

            try
            {
                Type propertyType = GetType(type, propertyName);
                typeCode = GetTypeCode(propertyType);
            }
            catch { }

            return typeCode;
        }

        /// <summary>
        /// Get Type name.
        /// </summary>
        /// <param name="className">Class name</param>
        /// <returns>Type name</returns>
        public static string GetTypeName(string className)
        {
            string typeName = "";

            try
            {
                Type type = GetType(className);
                typeName = GetTypeName(type);
            }
            catch { }

            return typeName;
        }

        /// <summary>
        /// Get Type name.
        /// </summary>
        /// <param name="type">Type</param>
        /// <returns>Type name</returns>
        public static string GetTypeName(Type type)
        {
            string typeName = "";

            try
            {
                typeName = type.ToString(); // System.Nullable[System.Int32]
                int index = typeName.IndexOf('[');
                if (index >= 0)
                    typeName = typeName.Substring(index + 1).Replace("]", "");
            }
            catch { }

            return typeName;
        }

        /// <summary>
        /// Get Property Type name.
        /// </summary>
        /// <param name="className">Class name</param>
        /// <param name="propertyName">Property name</param>
        /// <returns>Property Type name</returns>
        public static string GetTypeName(string className, string propertyName)
        {
            string typeName = "";

            try
            {
                Type propertyType = GetType(className, propertyName);
                typeName = GetTypeName(propertyType);
            }
            catch { }

            return typeName;
        }

        /// <summary>
        /// Get Property Type name.
        /// </summary>
        /// <param name="type">Type</param>
        /// <param name="propertyName">Property name</param>
        /// <returns>Property Type name</returns>
        public static string GetTypeName(Type type, string propertyName)
        {
            string typeName = "";

            try
            {
                Type propertyType = GetType(type, propertyName);
                typeName = GetTypeName(propertyType);
            }
            catch { }

            return typeName;
        }

        // Field

        /// <summary>
        /// Get Fields.
        /// </summary>
        /// <param name="type">Type</param>
        /// <returns>Fields</returns>
        public static List<string> GetFields(Type type)
        {
            List<string> result = new List<string>();
            BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;
            FieldInfo[] fields = type.GetFields(bindingFlags);
            foreach (FieldInfo field in fields)
            {
                result.Add(field.Name);
            }

            return result;
        }

        /// <summary>
        /// Get Field.
        /// </summary>
        /// <param name="type">Type name</param>
        /// <param name="fieldName">Field name</param>
        /// <returns>Property</returns>
        public static FieldInfo GetField(Type type, string fieldName)
        {
            BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            return type.GetField(fieldName, bindingFlags);
        }

        /// <summary>
        /// Get Field value.
        /// </summary>
        /// <param name="instance">Instance</param>
        /// <param name="fieldName">Field name</param>
        /// <returns></returns>
        public static object GetFieldValue(object instance, string fieldName)
        {
            Type type = instance.GetType();
            BindingFlags bindingFlags = BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;
            FieldInfo field = type.GetField(fieldName, bindingFlags);

            return field.GetValue(instance);
        }

        // Property

        /// <summary>
        /// Get Properties.
        /// </summary>
        /// <param name="type">Type</param>
        /// <returns>Properties</returns>
        public static List<string> GetProperties(Type type)
        {
            List<string> result = new List<string>();
            BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;
            PropertyInfo[] properties = type.GetProperties(bindingFlags);
            foreach (PropertyInfo property in properties)
            {
                result.Add(property.Name);
            }

            return result;
        }

        /// <summary>
        /// Get Property.
        /// </summary>
        /// <param name="type">Type name</param>
        /// <param name="propertyName">Property name</param>
        /// <returns>Property</returns>
        public static PropertyInfo GetProperty(Type type, string propertyName)
        {
            BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            return type.GetProperty(propertyName, bindingFlags);
        }

        /// <summary>
        /// Get Property value.
        /// </summary>
        /// <param name="instance">Instance</param>
        /// <param name="propertyName">Property name</param>
        /// <returns>Property value</returns>
        public static object GetPropertyValue(object instance, string propertyName)
        {
            Type type = instance.GetType();
            BindingFlags bindingFlags = BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;
            PropertyInfo property = type.GetProperty(propertyName, bindingFlags);

            //return property.GetValue(instance, null);
            return property.GetValue(instance);
        }

        /// <summary>
        /// Get Property value.
        /// </summary>
        /// <param name="type">Type</param>
        /// <param name="propertyName">Property name</param>
        /// <returns>Property value</returns>
        public static object GetStaticPropertyValue(Type type, string propertyName)
        {
            BindingFlags bindingFlags = BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;
            PropertyInfo property = type.GetProperty(propertyName, bindingFlags);

            //return property.GetValue(null, null); // static => object = null
            return property.GetValue(null); // static => object = null
        }

        /// <summary>
        /// Set Property value.
        /// </summary>
        /// <param name="instance">Instance</param>
        /// <param name="propertyName">Property name</param>
        /// <param name="value">Value</param>
        /// <returns>Property value</returns>
        public static void SetPropertyValue(object instance, string propertyName, object value)
        {
            Type type = instance.GetType();
            PropertyInfo property = GetProperty(type, propertyName);
            if (property != null)
            {
                property.SetValue(instance, value, null);
            }
        }

        #endregion Methods Reflection
    }
}


text:
[![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://raw.githubusercontent.com/mediaFORGE/gol/master/LICENSE)

This example demonstrates a case where you would have 2 loggers implemented with 2 different filters.

The first logger is an error logger and it will write to `stderr` all messages higher than `WARNING`.

The second logger is an info logger and it will write to `stdout` all messages lower or equal to `WARNING`.

```
$ go build example.go
$ go run example.go > info.log 2> error.log

$ ls
README.md		example		example.go	error.log			info.log

$ cat error.log
severity=EMERGENCY emergency=errorLog
severity=ERROR error=errorLog

$ cat info.log
severity=DEBUG debug=info
```

NOTE: if a message doesn't have a severity level it will also be filtered.

redpajama_set_name: RedPajamaGithub


text:
declare module 'mongoose-slug-hero' {
  import { Document, DocumentQuery, Model } from 'mongoose'

  export interface SlugHeroGlobalOptions {
    /**
     *  (global): The slug field name that will be added to the collection to store generated slug. Default: slug.
     */
    slugField?: string

    /**
     * (global): The slugs field name that will be added to the collection to store slug history. Default: slugs.
     */
    slugsField?: string

    /**
     * (global): Options for node-slug. Please refer to https://github.com/dodo/node-slug#options. Default: {lower: true}.
     */
    slugOptions?: any

    /**
     * (global): The name of collection to store sequences data. Default: _slug_ctrs.
     */
    counter?: string
  }

  export interface SlugHeroOptions extends SlugHeroGlobalOptions {
    /**
     * Name of slug-hero, this must be unique among collections. You can fill with the model name to make life easier.
     */
    doc: string

    /**
     * Name of your field that slug will generate for.
     */
    field: string

    /**
     * Array of field names for scope keys (see example: Scoped Slug).
     */
    scope?: string | string[]
  }

  /**
   * Model with mongoose slug hero functionalities.
   */
  export interface SlugHeroModel<T extends Document> extends Model<T> {
    /**
     * Generate slug if it's not exists yet.
     * @param callback done callback
     */
    ensureSlugIsExists(callback?: (err: any) => void)

    /**
     * Find document by slug.
     * @param slug slug value
     * @param callback done callback
     */
    findBySlug(
      slug: string,
      callback?: (err: any, result: T & Document) => void
    ): DocumentQuery<T[], T & Document>
  }

  import mongoose = require('mongoose')
  const pluginFn: (schema: mongoose.Schema) => void
  export default pluginFn
}


text:
#include "vinyl_space.h"
#include "vinyl_index.h"
#include "xrow.h"
#include "txn.h"
#include "vinyl.h"
#include "vy_stmt.h"

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

VinylSpace::VinylSpace(Engine *e)
	:Handler(e)
{}

void
VinylSpace::applyInitialJoinRow(struct space *space, struct request *request)
{
	assert(request->type == IPROTO_INSERT);
	assert(request->header != NULL);
	struct vy_env *env = ((VinylEngine *)space->handler->engine)->env;

	/* Check the tuple fields. */
	if (tuple_validate_raw(space->format, request->tuple))
		diag_raise();

	struct vy_tx *tx = vy_begin(env);
	if (tx == NULL)
		diag_raise();

	int64_t signature = request->header->lsn;

	if (vy_replace(tx, NULL, space, request))
		diag_raise();

	if (vy_prepare(env, tx)) {
		vy_rollback(env, tx);
		diag_raise();
	}
	if (vy_commit(env, tx, signature))
		panic("failed to commit vinyl transaction");
}

/*
 * Four cases:
 *  - insert in one index
 *  - insert in multiple indexes
 *  - replace in one index
 *  - replace in multiple indexes.
 */
struct tuple *
VinylSpace::executeReplace(struct txn *txn, struct space *space,
			   struct request *request)
{
	assert(request->index_id == 0);
	struct vy_tx *tx = (struct vy_tx *)txn->engine_tx;
	struct txn_stmt *stmt = txn_current_stmt(txn);

	if (vy_replace(tx, stmt, space, request))
		diag_raise();

	assert(stmt->new_tuple != NULL);
	return stmt->new_tuple;
}

struct tuple *
VinylSpace::executeDelete(struct txn *txn, struct space *space,
                          struct request *request)
{
	struct txn_stmt *stmt = txn_current_stmt(txn);
	struct vy_tx *tx = (struct vy_tx *) txn->engine_tx;
	if (vy_delete(tx, stmt, space, request))
		diag_raise();
	/*
	 * Delete may or may not set stmt->old_tuple, but we
	 * always return NULL.
	 */
	return NULL;
}

struct tuple *
VinylSpace::executeUpdate(struct txn *txn, struct space *space,
                          struct request *request)
{
	struct vy_tx *tx = (struct vy_tx *)txn->engine_tx;
	struct txn_stmt *stmt = txn_current_stmt(txn);
	if (vy_update(tx, stmt, space, request) != 0)
		diag_raise();
	return stmt->new_tuple;
}

void
VinylSpace::executeUpsert(struct txn *txn, struct space *space,
                           struct request *request)
{
	struct vy_tx *tx = (struct vy_tx *)txn->engine_tx;
	struct txn_stmt *stmt = txn_current_stmt(txn);
	if (vy_upsert(tx, stmt, space, request) != 0)
		diag_raise();
}

Index *
VinylSpace::createIndex(struct space *space, struct key_def *key_def)
{
	(void) space;
	VinylEngine *engine = (VinylEngine *) this->engine;
	if (key_def->type != TREE) {
		unreachable();
		return NULL;
	}
	return new VinylIndex(engine->env, key_def);
}

void
VinylSpace::dropIndex(Index *index)
{
	VinylIndex *i = (VinylIndex *)index;
	/* schedule asynchronous drop */
	vy_index_drop(i->db);
	i->db  = NULL;
	i->env = NULL;
}

void
VinylSpace::prepareAlterSpace(struct space *old_space, struct space *new_space)
{
	if (old_space->index_count &&
	    old_space->index_count <= new_space->index_count) {
		VinylEngine *engine = (VinylEngine *)old_space->handler->engine;
		Index *primary_index = index_find_xc(old_space, 0);
		if (vy_status(engine->env) == VINYL_ONLINE &&
		    primary_index->min(NULL, 0)) {
			/**
			 * If the space is not empty, then forbid new
			 * index create.
			 */
			tnt_raise(ClientError, ER_UNSUPPORTED, "Vinyl",
				  "altering not empty space");
		}
	}
}

void
VinylSpace::commitAlterSpace(struct space *old_space, struct space *new_space)
{
	if (new_space == NULL || new_space->index_count == 0) {
		/* This is a drop space. */
		return;
	}
	vy_commit_alter_space(old_space, new_space);
}


text:
import { PixelRatio, StatusBar } from "react-native";

import variable from "./../variables/platform";

export default (variables = variable) => {
  const platformStyle = variables.platformStyle;
  const platform = variables.platform;

  const headerTheme = {
    ".span": {
      height: 128,
      "NativeBase.Left": {
        alignSelf: "flex-start"
      },
      "NativeBase.Body": {
        alignSelf: "flex-end",
        alignItems: "flex-start",
        justifyContent: "center",
        paddingBottom: 26
      },
      "NativeBase.Right": {
        alignSelf: "flex-start"
      }
    },
    ".hasSubtitle": {
      "NativeBase.Body": {
        "NativeBase.Title": {
          fontSize: variables.titleFontSize - 2,
          fontFamily: variables.titleFontfamily,
          textAlign: "center",
          fontWeight: "500",
          paddingBottom: 3
        },
        "NativeBase.Subtitle": {
          fontSize: variables.subTitleFontSize,
          fontFamily: variables.titleFontfamily,
          color: variables.subtitleColor,
          textAlign: "center"
        }
      }
    },
    ".transparent": {
      backgroundColor: "transparent",
      borderBottomColor: "transparent",
      elevation: 0,
      shadowColor: null,
      shadowOffset: null,
      shadowRadius: null,
      shadowOpacity: null,
      paddingTop: platform === "android" ? StatusBar.currentHeight : undefined,
      height: platform === "android" ? variables.toolbarHeight + StatusBar.currentHeight : variables.toolbarHeight
    },
    ".noShadow": {
      elevation: 0,
      shadowColor: null,
      shadowOffset: null,
      shadowRadius: null,
      shadowOpacity: null
    },
    ".hasTabs": {
      elevation: 0,
      shadowColor: null,
      shadowOffset: null,
      shadowRadius: null,
      shadowOpacity: null,
      borderBottomWidth: null
    },
    ".hasSegment": {
      elevation: 0,
      shadowColor: null,
      shadowOffset: null,
      shadowRadius: null,
      shadowOpacity: null,
      borderBottomWidth: null,
      "NativeBase.Left": {
        flex: 0.3
      },
      "NativeBase.Right": {
        flex: 0.3
      },
      "NativeBase.Body": {
        flex: 1,
        "NativeBase.Segment": {
          marginRight: 0,
          alignSelf: "center",
          "NativeBase.Button": {
            paddingLeft: 0,
            paddingRight: 0
          }
        }
      }
    },
    ".noLeft": {
      "NativeBase.Left": {
        width: platform === "ios" ? undefined : 0,
        flex: platform === "ios" ? 1 : 0
      },
      "NativeBase.Body": {
        "NativeBase.Title": {
          paddingLeft: platform === "ios" ? undefined : 10
        },
        "NativeBase.Subtitle": {
          paddingLeft: platform === "ios" ? undefined : 10
        }
      }
    },
    "NativeBase.Button": {
      justifyContent: "center",
      alignSelf: "center",
      alignItems: "center",
      ".transparent": {
        "NativeBase.Text": {
          color: variables.toolbarBtnTextColor,
          fontWeight: "600"
        },
        "NativeBase.Icon": {
          color: variables.toolbarBtnColor
        },
        "NativeBase.IconNB": {
          color: variables.toolbarBtnColor
        },
        paddingHorizontal: variables.buttonPadding
      },
      paddingHorizontal: 15
    },
    ".searchBar": {
      "NativeBase.Item": {
        "NativeBase.Icon": {
          backgroundColor: "transparent",
          color: variables.dropdownLinkColor,
          fontSize: variables.toolbarSearchIconSize,
          alignItems: "center",
          marginTop: 2,
          paddingRight: 10,
          paddingLeft: 10
        },
        "NativeBase.IconNB": {
          backgroundColor: "transparent",
          color: null,
          alignSelf: "center"
        },
        "NativeBase.Input": {
          alignSelf: "center",
          lineHeight: null,
          height: variables.searchBarInputHeight
        },
        alignSelf: "center",
        alignItems: "center",
        justifyContent: "flex-start",
        flex: 1,
        height: variables.searchBarHeight,
        borderColor: "transparent",
        backgroundColor: variables.toolbarInputColor
      },
      "NativeBase.Button": {
        ".transparent": {
          "NativeBase.Text": {
            fontWeight: "500"
          },
          paddingHorizontal: null,
          paddingLeft: platform === "ios" ? 10 : null
        },
        paddingHorizontal: platform === "ios" ? undefined : null,
        width: platform === "ios" ? undefined : 0,
        height: platform === "ios" ? undefined : 0
      }
    },
    ".rounded": {
      "NativeBase.Item": {
        borderRadius:
          platform === "ios" && platformStyle !== "material" ? 25 : 3
      }
    },
    "NativeBase.Left": {
      "NativeBase.Button": {
        ".hasText": {
          marginLeft: -10,
          height: 30,
          "NativeBase.Icon": {
            color: variables.toolbarBtnColor,
            fontSize: variables.iconHeaderSize,
            marginTop: 2,
            marginRight: 5,
            marginLeft: 2
          },
          "NativeBase.Text": {
            color: variables.toolbarBtnTextColor,
            fontSize: platform === "ios" ? 17 : 0,
            marginLeft: 7,
            lineHeight: 19.5
          },
          "NativeBase.IconNB": {
            color: variables.toolbarBtnColor,
            fontSize: variables.iconHeaderSize,
            marginTop: 2,
            marginRight: 5,
            marginLeft: 2
          }
        },
        ".transparent": {
          marginLeft:
            platform === "ios" && platformStyle !== "material" ? -3 : 0,
          "NativeBase.Icon": {
            color: variables.toolbarBtnColor,
            fontSize:
              platform === "ios" && variables.platformStyle !== "material"
                ? variables.iconHeaderSize + 1
                : variables.iconHeaderSize,
            marginTop: 0,
            marginRight: 2,
            marginLeft: 1,
            paddingTop: 1
          },
          "NativeBase.IconNB": {
            color: variables.toolbarBtnColor,
            fontSize:
              platform === "ios" && variables.platformStyle !== "material"
                ? variables.iconHeaderSize + 1
                : variables.iconHeaderSize - 2,
            marginTop: 0,
            marginRight: 2,
            marginLeft: 1,
            paddingTop: 1
          },
          "NativeBase.Text": {
            color: variables.toolbarBtnTextColor,
            fontSize: platform === "ios" ? 17 : 0,
            top: platform === "ios" ? 1 : -1.5,
            paddingLeft:
              platform === "ios" && platformStyle !== "material" ? 2 : 5,
            paddingRight:
              platform === "ios" && platformStyle !== "material"
                ? undefined
                : 10
          },
          backgroundColor: "transparent",
          borderColor: null,
          elevation: 0,
          shadowColor: null,
          shadowOffset: null,
          shadowRadius: null,
          shadowOpacity: null
        },
        "NativeBase.Icon": {
          color: variables.toolbarBtnColor
        },
        "NativeBase.IconNB": {
          color: variables.toolbarBtnColor
        },
        alignSelf: null,
        paddingRight: variables.buttonPadding,
        paddingLeft: platform === "ios" && platformStyle !== "material" ? 4 : 8
      },
      flex: platform === "ios" && platformStyle !== "material" ? 1 : 0.4,
      alignSelf: "center",
      alignItems: "flex-start"
    },
    "NativeBase.Body": {
      flex: 1,
      alignItems:
        platform === "ios" && platformStyle !== "material"
          ? "center"
          : "flex-start",
      alignSelf: "center",
      "NativeBase.Segment": {
        borderWidth: 0,
        alignSelf: "flex-end",
        marginRight: platform === "ios" ? -40 : -55
      },
      "NativeBase.Button": {
        alignSelf: "center",
        ".transparent": {
          backgroundColor: "transparent"
        },
        "NativeBase.Icon": {
          color: variables.toolbarBtnColor
        },
        "NativeBase.IconNB": {
          color: variables.toolbarBtnColor
        },
        "NativeBase.Text": {
          color: variables.inverseTextColor,
          backgroundColor: "transparent"
        }
      }
    },
    "NativeBase.Right": {
      "NativeBase.Button": {
        ".hasText": {
          height: 30,
          "NativeBase.Icon": {
            color: variables.toolbarBtnColor,
            fontSize: variables.iconHeaderSize - 2,
            marginTop: 2,
            marginRight: 2,
            marginLeft: 5
          },
          "NativeBase.Text": {
            color: variables.toolbarBtnTextColor,
            fontSize: platform === "ios" ? 17 : 14,
            lineHeight: 19.5
          },
          "NativeBase.IconNB": {
            color: variables.toolbarBtnColor,
            fontSize: variables.iconHeaderSize - 2,
            marginTop: 2,
            marginRight: 2,
            marginLeft: 5
          }
        },
        ".transparent": {
          marginRight: platform === "ios" ? -9 : -5,
          paddingLeft: 15,
          paddingRight: 12,
          paddingHorizontal: 15,
          borderRadius: 50,
          "NativeBase.Icon": {
            color: variables.toolbarBtnColor,
            fontSize:
              platform === "ios" && variables.platformStyle !== "material"
                ? variables.iconHeaderSize - 9
                : variables.iconHeaderSize - 2,
            marginTop: 0,
            marginLeft: 2,
            marginRight: 0
            // paddingTop: 0
          },
          "NativeBase.IconNB": {
            color: variables.toolbarBtnColor,
            fontSize:
              platform === "ios" && variables.platformStyle !== "material"
                ? variables.iconHeaderSize - 9
                : variables.iconHeaderSize - 2,
            marginTop: 0,
            marginLeft: 2,
            marginRight: 0
            // paddingTop: 0
          },
          "NativeBase.Text": {
            color: variables.toolbarBtnTextColor,
            fontSize: platform === "ios" ? 17 : 14,
            top: platform === "ios" ? 1 : -1.5,
            paddingRight:
              platform === "ios" && variables.platformStyle !== "material"
                ? 0
                : undefined
          },
          backgroundColor: "transparent",
          borderColor: null,
          elevation: 0,
          shadowColor: null,
          shadowOffset: null,
          shadowRadius: null,
          shadowOpacity: null
        },
        "NativeBase.Icon": {
          color: variables.toolbarBtnColor
        },
        "NativeBase.IconNB": {
          color: variables.toolbarBtnColor
        },
        alignSelf: null,
        paddingHorizontal: variables.buttonPadding
      },
      flex: 1,
      alignSelf: "center",
      alignItems: "flex-end",
      flexDirection: "row",
      justifyContent: "flex-end"
    },
    backgroundColor: variables.toolbarDefaultBg,
    flexDirection: "row",
    // paddingHorizontal: 10,
    paddingLeft:
      platform === "ios" && variables.platformStyle !== "material" ? 6 : 10,
    paddingRight: 10,
    justifyContent: "center",
    paddingTop: platform === "ios" ? 18 : 0,
    borderBottomWidth:
      platform === "ios" ? 1 / PixelRatio.getPixelSizeForLayoutSize(1) : 0,
    borderBottomColor: variables.toolbarDefaultBorder,
    height:
      variables.platform === "ios" && variables.platformStyle === "material"
        ? variables.toolbarHeight + StatusBar.height
        : variables.toolbarHeight,
    elevation: 3,
    shadowColor: platformStyle === "material" ? "#000" : undefined,
    shadowOffset:
      platformStyle === "material" ? { width: 0, height: 2 } : undefined,
    shadowOpacity: platformStyle === "material" ? 0.2 : undefined,
    shadowRadius: platformStyle === "material" ? 1.2 : undefined,
    top: 0,
    left: 0,
    right: 0
  };

  return headerTheme;
};