本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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));
}
示例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();
}
示例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();
}
示例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);
}
示例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));
}