Esempio n. 1
0
        /// <summary>
        /// Generates the name of a column for a given property type according to the naming conventions configuration
        /// </summary>
        /// <param name="property">The property</param>
        /// <returns>The table name</returns>
        public string ToColumnName(MemberInfo property)
        {
            string result       = null;
            string propertyName = property.Name;

            switch (namingConventions.ColumnsNamingConvention)
            {
            case ColumnsNamingConvention.Default: result = propertyName; break;

            case ColumnsNamingConvention.CamelCase: result = NamingHelper.ToCamelCase(propertyName); break;

            case ColumnsNamingConvention.PascalCase: result = NamingHelper.ToPascalCase(propertyName); break;

            case ColumnsNamingConvention.Lowercase: result = NamingHelper.ToLowercase(propertyName); break;

            case ColumnsNamingConvention.Uppercase: result = NamingHelper.ToUppercase(propertyName); break;

            case ColumnsNamingConvention.Custom:
            {
                if (namingConventions.ColumnsCustomNamingConvention == null)
                {
                    throw new ConfigurationErrorsException(string.Format(ExceptionMessages.CustomConventionNotFound, typeof(ComponentsTableNamingConvention).Name));
                }

                result = namingConventions.ColumnsCustomNamingConvention(property);
            }; break;
            }

            return(result);
        }