Пример #1
0
        public void ConvertStringWithPrefix()
        {
            var formatter = new PrefixedTextFormatter("_");

            Assert.AreEqual("_ColumnName", formatter.FormatText("ColumnName"));
            Assert.AreEqual("_column_name", formatter.FormatText("column_name"));
        }
        public static ITextFormatter GetTextFormatter(ApplicationPreferences applicationPreferences)
        {
            ITextFormatter formatter;

            switch (applicationPreferences.FieldNamingConvention)
            {
            case FieldNamingConvention.SameAsDatabase:
                formatter = new UnformattedTextFormatter();
                break;

            case FieldNamingConvention.CamelCase:
                formatter = new CamelCaseTextFormatter();
                break;

            case FieldNamingConvention.PascalCase:
                formatter = new PascalCaseTextFormatter();
                break;

            case FieldNamingConvention.Prefixed:
                formatter = new PrefixedTextFormatter(applicationPreferences.Prefix);
                break;

            default:
                throw new Exception("Invalid or unsupported field naming convention.");
            }

            formatter.PrefixRemovalList = applicationPreferences.FieldPrefixRemovalList;

            return(formatter);
        }
Пример #3
0
        public static ITextFormatter GetTextFormatter(ApplicationPreferences applicationPreferences)
        {
            ITextFormatter formatter;
            switch(applicationPreferences.FieldNamingConvention)
            {
                case FieldNamingConvention.SameAsDatabase:
                    formatter = new UnformattedTextFormatter();
                    break;
                case FieldNamingConvention.CamelCase:
                    formatter = new CamelCaseTextFormatter();
                    break;
                case FieldNamingConvention.PascalCase:
                    formatter = new PascalCaseTextFormatter();
                    break;
                case FieldNamingConvention.Prefixed:
                    formatter = new PrefixedTextFormatter(applicationPreferences.Prefix);
                    break;
                default:
                    throw new Exception("Invalid or unsupported field naming convention.");
            }

            formatter.PrefixRemovalList = applicationPreferences.FieldPrefixRemovalList;

            return formatter;
        }