当前位置: 首页>>代码示例>>C#>>正文


C# ITextFormatter.FormatText方法代码示例

本文整理汇总了C#中ITextFormatter.FormatText方法的典型用法代码示例。如果您正苦于以下问题:C# ITextFormatter.FormatText方法的具体用法?C# ITextFormatter.FormatText怎么用?C# ITextFormatter.FormatText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITextFormatter的用法示例。


在下文中一共展示了ITextFormatter.FormatText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompositeIdMap

        public string CompositeIdMap(IList<Column> columns, ITextFormatter formatter)
        {
            var builder = new StringBuilder();

            switch (_language)
            {
                case Language.CSharp:
                    builder.AppendLine("ComposedId(compId =>");
                    builder.AppendLine("\t\t\t\t{");
                    foreach (var column in columns)
                    {
                        builder.AppendLine("\t\t\t\t\tcompId.Property(x => x." + formatter.FormatText(column.Name) + ", m => m.Column(\"" + column.Name + "\"));");
                    }
                    builder.Append("\t\t\t\t});");
                    break;
                case Language.VB:
                    builder.AppendLine("ComposedId(Sub(compId)");
                    foreach (var column in columns)
                    {
                        builder.AppendLine("\t\t\t\t\tcompId.Property(Function(x) x." + formatter.FormatText(column.Name) + ", Sub(m) m.Column(\"" + column.Name + "\"))");
                    }
                    builder.AppendLine("\t\t\t\tEnd Sub)");
                    break;
            }

            return builder.ToString();
        }
开发者ID:stantoxt,项目名称:NHibernateMappingGenerator_Patched,代码行数:27,代码来源:DBColumnMapper.cs

示例2: IdMap

        public string IdMap(Column column, ITextFormatter formatter)
        {
            var mapList = new List<string>();
            var propertyName = formatter.FormatText(column.Name);

            if (column.Name.ToLower() != propertyName.ToLower())
            {
                mapList.Add("map.Column(\"" + column.Name + "\")");
            }
            mapList.Add(column.IsIdentity ? "map.Generator(Generators.Identity)" : "map.Generator(Generators.Assigned)");

            // Outer property definition
            return FormatCode("Id", propertyName, mapList);
        }
开发者ID:stantoxt,项目名称:NHibernateMappingGenerator_Patched,代码行数:14,代码来源:DBColumnMapper.cs

示例3: Map

        public string Map(Column column, ITextFormatter Formatter, bool includeLengthAndScale = true)
        {
            var mappedStrBuilder = new StringBuilder(string.Format("Map(x => x.{0})", Formatter.FormatText(column.Name)));
            mappedStrBuilder.Append(Constants.Dot);
            mappedStrBuilder.Append("Column(\"" + column.Name + "\")");

            if (!column.IsNullable)
            {
                mappedStrBuilder.Append(Constants.Dot);
                mappedStrBuilder.Append("Not.Nullable()");
            }

            if (column.IsUnique)
            {
                mappedStrBuilder.Append(Constants.Dot);
                mappedStrBuilder.Append("Unique()");
            }

            if (column.DataLength.GetValueOrDefault() > 0 & includeLengthAndScale)
            {
                mappedStrBuilder.Append(Constants.Dot);
                mappedStrBuilder.Append("Length(" + column.DataLength + ")");
            }
            else
            {
                if (column.DataPrecision.GetValueOrDefault(0) > 0 & includeLengthAndScale)
                {
                    mappedStrBuilder.Append(Constants.Dot);
                    mappedStrBuilder.Append("Precision(" + column.DataPrecision + ")");
                }

                if (column.DataScale.GetValueOrDefault(0) > 0 & includeLengthAndScale)
                {
                    mappedStrBuilder.Append(Constants.Dot);
                    mappedStrBuilder.Append("Scale(" + column.DataScale + ")");
                }
            }

            mappedStrBuilder.Append(Constants.SemiColon);
            return mappedStrBuilder.ToString();
        }
开发者ID:palfrey,项目名称:nmg,代码行数:41,代码来源:DBColumnMapper.cs

示例4: GetIdMapCodeSnippetStatement

        private static CodeSnippetStatement GetIdMapCodeSnippetStatement(PrimaryKey primaryKey, Table table, ITextFormatter formatter)
        {
            var keyPropertyBuilder = new StringBuilder(primaryKey.Columns.Count);
            bool first = true;
            foreach (Column pkColumn in primaryKey.Columns)
            {
                var propertyName = formatter.FormatText(pkColumn.Name);
                var fieldName = FixPropertyWithSameClassName(propertyName, table.Name);
                var pkAlsoFkQty = (from fk in table.ForeignKeys.Where(fk => fk.UniquePropertyName == pkColumn.Name) select fk).Count();
                if (pkAlsoFkQty > 0) fieldName = fieldName + "Id";
             var tmp = String.Format(".KeyProperty(x => x.{0}, \"{1}\")",fieldName, pkColumn.Name);
                keyPropertyBuilder.Append(first ? tmp : "\n" + TABS + "             " + tmp);
                first = false;
            }

            return new CodeSnippetStatement(TABS + string.Format("CompositeId(){0};", keyPropertyBuilder));
        }
开发者ID:HongJunRen,项目名称:NMG,代码行数:17,代码来源:FluentGenerator.cs

示例5: IdSequenceMap

        //Id(x => x.Id, map =>
        //{
        //    map.Column("ID");
        //    map.Generator(Generators.Sequence, g => g.Params(new { sequence = "TABLE_SEQ" }));
        //});
        public string IdSequenceMap(Column column, string sequenceName, ITextFormatter formatter)
        {
            var builder = new StringBuilder();
            switch (_language)
            {
                case Language.CSharp:
                    builder.AppendFormat("Id(x => x.{0}, map => ", formatter.FormatText(column.Name));
                    builder.AppendLine();
                    builder.AppendLine("\t\t\t\t{");
                    builder.AppendLine("\t\t\t\t\tmap.Column(\"" + column.Name + "\");");
                    builder.AppendLine("\t\t\t\t\tmap.Generator(Generators.Sequence, g => g.Params(new { sequence = \"" + sequenceName + "\" }));");
                    builder.Append("\t\t\t\t});");
                    break;
                case Language.VB:
                    builder.AppendFormat("Id(Function(x) x.{0}, Sub(map)", formatter.FormatText(column.Name));
                    builder.AppendLine();
                    builder.AppendLine("\t\t\t\t\tmap.Column(\"" + column.Name + "\")");
                    builder.AppendLine("\t\t\t\t\tmap.Generator(Generators.Sequence, Function(g) g.Params(New { sequence = \"" + sequenceName + "\" }))");
                    builder.Append("\t\t\t\tEnd Sub)");
                    break;
            }

            return builder.ToString();
        }
开发者ID:stantoxt,项目名称:NHibernateMappingGenerator_Patched,代码行数:29,代码来源:DBColumnMapper.cs

示例6: Reference

        public string Reference(ForeignKey fk, ITextFormatter formatter)
        {
            var builder = new StringBuilder();
            if (fk.Columns.Count() == 1)
            {
                var mapList = new List<string>();
                mapList.Add("map.Column(\"" + fk.Columns.First().Name + "\")");

                // PropertyRef - Used with a FK that doesnt map to a primary key on referenced table.
                if (!string.IsNullOrEmpty(fk.Columns.First().ForeignKeyColumnName))
                {
                    mapList.Add("map.PropertyRef(\"" + formatter.FormatText(fk.Columns.First().ForeignKeyColumnName) + "\")");
                }
                if (fk.Columns.First().IsNullable)
                {
                    mapList.Add("map.NotNullable(true)");
                }
                mapList.Add("map.Cascade(Cascade.None)");
                builder.AppendLine(FormatCode("\t\t\tManyToOne",formatter.FormatSingular(fk.UniquePropertyName),mapList));
            }
            else
            {
                // Composite Foreign Key
                // eg ManyToOne(x => x.TesteHeader, map => map.Columns(new Action<IColumnMapper>[] { x => x.Name("HeadIdOne"), x => x.Name("HeadIdTwo") }));
                if (_language == Language.CSharp)
                {
                    builder.AppendFormat(
                        "\t\t\tManyToOne(x => x.{0}, map => map.Columns(new Action<IColumnMapper>[] {{ ",
                        formatter.FormatSingular(fk.UniquePropertyName));

                    var lastColumn = fk.Columns.Last();
                    foreach (var column in fk.Columns)
                    {
                        builder.AppendFormat("x => x.Name(\"{0}\")", column.Name);

                        var isLastColumn = lastColumn == column;
                        if (!isLastColumn)
                        {
                            builder.Append(", ");
                        }
                    }

                    builder.Append(" }));");
                }
                else if (_language == Language.VB)
                {
                    builder.AppendFormat(
                        "\t\t\tManyToOne(Function(x) x.{0}, Sub(map) map.Columns(new Action<IColumnMapper>[] {{",
                        formatter.FormatSingular(fk.UniquePropertyName));

                    var lastColumn = fk.Columns.Last();
                    foreach (var column in fk.Columns)
                    {
                        builder.AppendFormat("x.Name(\"{0}\")", column.Name);

                        var isLastColumn = lastColumn == column;
                        if (!isLastColumn)
                        {
                            builder.Append(", ");
                        }
                    }

                    builder.Append(" }))");
                }
            }
            return builder.ToString();
        }
开发者ID:stantoxt,项目名称:NHibernateMappingGenerator_Patched,代码行数:67,代码来源:DBColumnMapper.cs

示例7: Map

        //Property(x => x.Name, map =>
        //                {
        //                    map.Column("NAME");
        //                    map.NotNullable(true);
        //                    map.Length(200);
        //                    map.Unique(true);
        //                });
        public string Map(Column column, ITextFormatter formatter, bool includeLengthAndScale = true)
        {
            var propertyName = formatter.FormatText(column.Name);
            var mapList = new List<string>();

            // Column
            if (column.Name.ToLower() != propertyName.ToLower())
            {
                mapList.Add("map.Column(\"" + column.Name + "\")");
            }
            // Not Null
            if (!column.IsNullable)
            {
                mapList.Add("map.NotNullable(true)");
            }
            // Unique
            if (column.IsUnique)
            {
                mapList.Add("map.Unique(true)");
            }
            // Length
            if (column.DataLength.GetValueOrDefault() > 0 & includeLengthAndScale)
            {
                mapList.Add("map.Length(" + column.DataLength + ")");
            }
            else
            {
                // Precision
                if (column.DataPrecision.GetValueOrDefault(0) > 0 & includeLengthAndScale)
                {
                    mapList.Add("map.Precision(" + column.DataPrecision + ")");
                }
                // Scale
                if (column.DataScale.GetValueOrDefault(0) > 0 & includeLengthAndScale)
                {
                    mapList.Add("map.Scale(" + column.DataScale + ")");
                }
            }

            // m.Access(Accessor.Field);
            if (_applicationPreferences.FieldGenerationConvention == FieldGenerationConvention.Field)
            {
                mapList.Add("map.Access(Accessor.Field)");
            }

            // Outer property definition
            return FormatCode("Property", propertyName, mapList);
        }
开发者ID:stantoxt,项目名称:NHibernateMappingGenerator_Patched,代码行数:55,代码来源:DBColumnMapper.cs

示例8: GetIdMapCodeSnippetStatement

        private static CodeSnippetStatement GetIdMapCodeSnippetStatement(PrimaryKey primaryKey, ITextFormatter formatter)
        {
            var keyPropertyBuilder = new StringBuilder(primaryKey.Columns.Count);
            foreach (Column pkColumn in primaryKey.Columns)
            {
                keyPropertyBuilder.Append(String.Format(".KeyProperty(x => x.{0}, \"{1}\")", formatter.FormatText(pkColumn.Name), pkColumn.Name));
            }

            return new CodeSnippetStatement(TABS + string.Format("CompositeId(){0};", keyPropertyBuilder));
        }
开发者ID:palfrey,项目名称:nmg,代码行数:10,代码来源:FluentGenerator.cs


注:本文中的ITextFormatter.FormatText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。