Here are the examples of the csharp api System.Text.StringBuilder.Append(char) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
8245 Examples
19
View Source File : Edi.cs
License : MIT License
Project Creator : 0ffffffffh
License : MIT License
Project Creator : 0ffffffffh
private static void GenSessionId()
{
StringBuilder sb = new StringBuilder();
string hx = "abcdefgh0123456789";
Random rnd = new Random();
for (int i=0;i<16;i++)
{
sb.Append(hx[rnd.Next(hx.Length)]);
}
sessionId = sb.ToString();
sb.Clear();
sb = null;
}
19
View Source File : IndexAndSearchHandler.cs
License : MIT License
Project Creator : 0ffffffffh
License : MIT License
Project Creator : 0ffffffffh
private string NormalizeTerm(string s)
{
StringBuilder sb = new StringBuilder();
foreach (var c in s)
{
if (char.IsLetterOrDigit(c) || c == ' ')
sb.Append(char.ToLower(c));
else if (char.IsSeparator(c))
sb.Append(' ');
}
s = sb.ToString();
sb.Clear();
sb = null;
return s;
}
19
View Source File : CelesteNetPlayerListComponent.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
private void AppendState(StringBuilder builder, DataPlayerState state) {
if (!string.IsNullOrWhiteSpace(state.SID))
builder
.Append(" @ ")
.Append(AreaDataExt.Get(state.SID)?.Name?.DialogCleanOrNull(Dialog.Languages["english"]) ?? state.SID)
.Append(" ")
.Append((char) ('A' + (int) state.Mode))
.Append(" ")
.Append(state.Level);
if (state.Idle)
builder.Append(" :celestenet_idle:");
}
19
View Source File : CelesteNetUtils.BinaryRWCompat.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
[Obsolete("Use CelesteNetBinaryReader instead.")]
public static string ReadNetString(this BinaryReader stream) {
StringBuilder sb = new();
char c;
while ((c = stream.ReadChar()) != '\0') {
sb.Append(c);
if (sb.Length > 4096)
throw new Exception("String too long.");
}
return sb.ToString();
}
19
View Source File : FileSystemHelper.cs
License : zlib License
Project Creator : 0x0ade
License : zlib License
Project Creator : 0x0ade
public static string ChangePath(string path, char separator) {
// Can't trust File.Exists if MONO_IOMAP_ALL is set.
if (!MONO_IOMAP_ALL) {
string pathMaybe = path;
// Check if target exists in the first place.
if (Directory.Exists(path) || File.Exists(path))
return pathMaybe;
// Try a simpler fix first: Maybe the casing is already correct...
pathMaybe = path.Replace('/', separator).Replace('\\', separator);
if (Directory.Exists(pathMaybe) || File.Exists(pathMaybe))
return pathMaybe;
// Fall back to the slow rebuild.
}
// Check if the path has been rebuilt before.
Dictionary<string, string> cachedPaths;
if (!_CachedChanges.TryGetValue(separator, out cachedPaths))
_CachedChanges[separator] = cachedPaths = new Dictionary<string, string>();
string cachedPath;
if (cachedPaths.TryGetValue(path, out cachedPath))
return cachedPath;
// Split and rebuild path.
string[] pathSplit = path.Split(DirectorySeparatorChars);
StringBuilder builder = new StringBuilder();
bool unixRooted = false;
if (Path.IsPathRooted(path)) {
// The first element in a rooted path will always be correct.
// On Windows, this will be the drive letter.
// On Unix and Unix-like systems, this will be empty.
if (unixRooted = (builder.Length == 0))
// Path is rooted, but the path separator is the root.
builder.Append(separator);
else
builder.Append(pathSplit[0]);
}
for (int i = 1; i < pathSplit.Length; i++) {
string next;
if (i < pathSplit.Length - 1)
next = GetDirectory(builder.ToString(), pathSplit[i]);
else
next = GetTarget(builder.ToString(), pathSplit[i]);
next = next ?? pathSplit[i];
if (i != 1 || !unixRooted)
builder.Append(separator);
builder.Append(next);
}
return cachedPaths[path] = builder.ToString();
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprBooleanAnd(ExprBooleanAnd expr, IExpr? parent)
{
if (expr.Left is ExprBooleanOr)
{
this.AcceptPar('(', expr.Left, ')', expr);
this.Builder.Append("AND");
}
else
{
expr.Left.Accept(this, expr);
this.Builder.Append(" AND");
}
if (expr.Right is ExprBooleanOr)
{
this.AcceptPar('(', expr.Right, ')', expr);
}
else
{
this.Builder.Append(' ');
expr.Right.Accept(this, expr);
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprBooleanNot(ExprBooleanNot expr, IExpr? parent)
{
this.Builder.Append("NOT");
if (expr.Expr is ExprPredicate)
{
this.Builder.Append(' ');
expr.Expr.Accept(this, expr);
}
else
{
this.AcceptPar('(', expr.Expr, ')', expr);
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprBooleanEq(ExprBooleanEq exprBooleanEq, IExpr? parent)
{
exprBooleanEq.Left.Accept(this, exprBooleanEq);
this.Builder.Append('=');
exprBooleanEq.Right.Accept(this, exprBooleanEq);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprBooleanGt(ExprBooleanGt booleanGt, IExpr? parent)
{
booleanGt.Left.Accept(this, booleanGt);
this.Builder.Append('>');
booleanGt.Right.Accept(this, booleanGt);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprBooleanLt(ExprBooleanLt booleanLt, IExpr? parent)
{
booleanLt.Left.Accept(this, booleanLt);
this.Builder.Append('<');
booleanLt.Right.Accept(this, booleanLt);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprStringLiteral(ExprStringLiteral stringLiteral, IExpr? parent)
{
if (stringLiteral.Value == null)
{
this.AppendNull();
return true;
}
this.AppendUnicodePrefix(stringLiteral.Value);
this.Builder.Append('\'');
if (stringLiteral.Value != null)
{
this.EscapeStringLiteral(this.Builder, stringLiteral.Value);
}
this.Builder.Append('\'');
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprDateTimeLiteral(ExprDateTimeLiteral dateTimeLiteral, IExpr? parent)
{
if (!dateTimeLiteral.Value.HasValue)
{
this.AppendNull();
}
else
{
this.Builder.Append('\'');
if (dateTimeLiteral.Value.Value.TimeOfDay != TimeSpan.Zero)
{
this.Builder.Append(dateTimeLiteral.Value.Value.ToString("yyyy-MM-ddTHH:mm:ss.fff"));
}
else
{
this.Builder.Append(dateTimeLiteral.Value.Value.ToString("yyyy-MM-dd"));
}
this.Builder.Append('\'');
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprSum(ExprSum exprSum, IExpr? parent)
{
exprSum.Left.Accept(this, exprSum);
this.Builder.Append('+');
exprSum.Right.Accept(this, exprSum);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprSub(ExprSub exprSub, IExpr? parent)
{
exprSub.Left.Accept(this, exprSub);
this.Builder.Append('-');
this.CheckPlusMinusParenthesizes(exprSub.Right, exprSub);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprMul(ExprMul exprMul, IExpr? parent)
{
this.CheckPlusMinusParenthesizes(exprMul.Left, exprMul);
this.Builder.Append('*');
this.CheckPlusMinusParenthesizes(exprMul.Right, exprMul);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprDiv(ExprDiv exprDiv, IExpr? parent)
{
this.CheckPlusMinusParenthesizes(exprDiv.Left, exprDiv);
this.Builder.Append('/');
this.CheckPlusMinusParenthesizes(exprDiv.Right, exprDiv);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprModulo(ExprModulo exprModulo, IExpr? arg)
{
this.CheckPlusMinusParenthesizes(exprModulo.Left, exprModulo);
this.Builder.Append('%');
this.CheckPlusMinusParenthesizes(exprModulo.Right, exprModulo);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
private void CheckPlusMinusParenthesizes(ExprValue exp, IExpr? parent)
{
if (exp is ExprSum || exp is ExprSub)
{
this.Builder.Append('(');
exp.Accept(this, parent);
this.Builder.Append(')');
}
else
{
exp.Accept(this, parent);
}
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprOutputAction(ExprOutputAction exprOutputAction, IExpr? parent)
{
this.Builder.Append("$ACTION");
if (exprOutputAction.Alias != null)
{
this.Builder.Append(' ');
exprOutputAction.Alias.Accept(this, exprOutputAction);
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprAggregateFunction(ExprAggregateFunction exprAggregateFunction, IExpr? parent)
{
exprAggregateFunction.Name.Accept(this, exprAggregateFunction);
this.Builder.Append('(');
if (exprAggregateFunction.IsDistinct)
{
this.Builder.Append("DISTINCT ");
}
exprAggregateFunction.Expression.Accept(this, exprAggregateFunction);
this.Builder.Append(')');
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprScalarFunction(ExprScalarFunction exprScalarFunction, IExpr? parent)
{
if (exprScalarFunction.Schema != null)
{
if (exprScalarFunction.Schema.Accept(this, exprScalarFunction))
{
this.Builder.Append('.');
}
}
exprScalarFunction.Name.Accept(this, exprScalarFunction);
if (exprScalarFunction.Arguments != null)
{
this.replacedertNotEmptyList(exprScalarFunction.Arguments, "Argument list cannot be empty");
this.AcceptListComaSeparatedPar('(', exprScalarFunction.Arguments, ')', exprScalarFunction);
}
else
{
this.Builder.Append('(');
this.Builder.Append(')');
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprreplacedyticFunction(ExprreplacedyticFunction exprreplacedyticFunction, IExpr? parent)
{
exprreplacedyticFunction.Name.Accept(this, exprreplacedyticFunction);
this.Builder.Append('(');
if (exprreplacedyticFunction.Arguments != null)
{
this.replacedertNotEmptyList(exprreplacedyticFunction.Arguments, "Arguments list cannot be empty");
this.AcceptListComaSeparated(exprreplacedyticFunction.Arguments, exprreplacedyticFunction);
}
this.Builder.Append(')');
exprreplacedyticFunction.Over.Accept(this, exprreplacedyticFunction);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprOver(ExprOver exprOver, IExpr? parent)
{
this.Builder.Append("OVER(");
if (exprOver.Parreplacedions != null)
{
this.replacedertNotEmptyList(exprOver.Parreplacedions, "Parreplacedion list cannot be empty");
this.Builder.Append("PARreplacedION BY ");
this.AcceptListComaSeparated(exprOver.Parreplacedions, exprOver);
}
if (exprOver.OrderBy != null)
{
if (exprOver.Parreplacedions != null)
{
this.Builder.Append(' ');
}
this.Builder.Append("ORDER BY ");
exprOver.OrderBy.Accept(this, exprOver);
}
if (exprOver.FrameClause != null)
{
this.Builder.Append(' ');
exprOver.FrameClause.Accept(this, exprOver);
}
this.Builder.Append(")");
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprCase(ExprCase exprCase, IExpr? parent)
{
this.replacedertNotEmptyList(exprCase.Cases, "Cases cannot be empty");
this.Builder.Append("CASE");
for (int i = 0; i < exprCase.Cases.Count; i++)
{
this.Builder.Append(' ');
exprCase.Cases[i].Accept(this, exprCase);
}
this.Builder.Append(" ELSE ");
exprCase.DefaultValue.Accept(this, exprCase);
this.Builder.Append(" END");
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprFuncCoalesce(ExprFuncCoalesce exprFuncCoalesce, IExpr? parent)
{
this.Builder.Append("COALESCE(");
exprFuncCoalesce.Test.Accept(this, exprFuncCoalesce);
this.Builder.Append(',');
this.replacedertNotEmptyList(exprFuncCoalesce.Alts, "Alt argument list cannot be empty in 'COALESCE' function call");
this.AcceptListComaSeparated(exprFuncCoalesce.Alts, exprFuncCoalesce);
this.Builder.Append(')');
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprColumn(ExprColumn exprColumn, IExpr? parent)
{
if (exprColumn.Source != null)
{
exprColumn.Source.Accept(this, exprColumn);
this.Builder.Append('.');
}
exprColumn.ColumnName.Accept(this, exprColumn);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprTable(ExprTable exprTable, IExpr? parent)
{
exprTable.FullName.Accept(this, exprTable);
if (exprTable.Alias != null)
{
this.Builder.Append(' ');
exprTable.Alias.Accept(this, exprTable);
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprAllColumns(ExprAllColumns exprAllColumns, IExpr? parent)
{
if (exprAllColumns.Source != null)
{
exprAllColumns.Source.Accept(this, exprAllColumns);
this.Builder.Append('.');
}
this.Builder.Append('*');
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
protected bool VisitExprTableFullNameCommon(ExprTableFullName exprTableFullName, IExpr? parent)
{
if (exprTableFullName.DbSchema != null)
{
if (exprTableFullName.DbSchema.Accept(this, exprTableFullName))
{
this.Builder.Append('.');
}
}
exprTableFullName.TableName.Accept(this, exprTableFullName);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprAliasedColumn(ExprAliasedColumn exprAliasedColumn, IExpr? parent)
{
exprAliasedColumn.Column.Accept(this, exprAliasedColumn);
if (exprAliasedColumn.Alias != null)
{
this.Builder.Append(' ');
exprAliasedColumn.Alias?.Accept(this, exprAliasedColumn);
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprAliasedColumnName(ExprAliasedColumnName exprAliasedColumnName, IExpr? parent)
{
exprAliasedColumnName.Column.Accept(this, exprAliasedColumnName);
if (exprAliasedColumnName.Alias != null)
{
this.Builder.Append(' ');
exprAliasedColumnName.Alias.Accept(this, exprAliasedColumnName);
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprAliasedSelecting(ExprAliasedSelecting exprAliasedSelecting, IExpr? parent)
{
exprAliasedSelecting.Value.Accept(this, exprAliasedSelecting);
this.Builder.Append(' ');
exprAliasedSelecting.Alias.Accept(this, exprAliasedSelecting);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprDbSchemaCommon(ExprDbSchema exprDbSchema, IExpr? parent)
{
if (exprDbSchema.Database != null)
{
exprDbSchema.Database.Accept(this, exprDbSchema);
this.Builder.Append('.');
}
exprDbSchema.Schema.Accept(this, exprDbSchema);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprTableValueConstructor(ExprTableValueConstructor tableValueConstructor, IExpr? parent)
{
this.Builder.Append("VALUES ");
for (var i = 0; i < tableValueConstructor.Items.Count; i++)
{
var rowValue = tableValueConstructor.Items[i];
if (i>0)
{
this.Builder.Append(',');
}
rowValue.Accept(this, tableValueConstructor);
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprColumnSetClause(ExprColumnSetClause columnSetClause, IExpr? parent)
{
columnSetClause.Column.Accept(this, columnSetClause);
this.Builder.Append('=');
columnSetClause.Value.Accept(this, columnSetClause);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
protected void GenericInsert(ExprInsert exprInsert, Action? middleHandler, Action? endHandler)
{
this.Builder.Append("INSERT INTO ");
exprInsert.Target.Accept(this, exprInsert);
if (exprInsert.TargetColumns != null)
{
this.replacedertNotEmptyList(exprInsert.TargetColumns, "Insert column list cannot be empty");
this.AcceptListComaSeparatedPar('(', exprInsert.TargetColumns, ')', exprInsert);
}
if (middleHandler != null)
{
this.Builder.Append(' ');
middleHandler();
}
this.Builder.Append(' ');
exprInsert.Source.Accept(this, exprInsert);
if (endHandler != null)
{
this.Builder.Append(' ');
endHandler();
}
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprInsertValues(ExprInsertValues exprInsertValues, IExpr? parent)
{
if (exprInsertValues.Items.Count < 1)
{
throw new SqExpressException("Insert values should have at least one record");
}
this.Builder.Append("VALUES ");
for (var i = 0; i < exprInsertValues.Items.Count; i++)
{
var rowValue = exprInsertValues.Items[i];
if (i > 0)
{
this.Builder.Append(',');
}
rowValue.Accept(this, exprInsertValues);
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprList(ExprList exprList, IExpr? parent)
{
for (var index = 0; index < exprList.Expressions.Count; index++)
{
var expr = exprList.Expressions[index];
if (index != 0 && exprList.Expressions[index-1] is not ExprStatement)
{
this.Builder.Append(';');
}
expr.Accept(this, exprList);
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
public bool VisitExprQueryList(ExprQueryList exprList, IExpr? parent)
{
for (var index = 0; index < exprList.Expressions.Count; index++)
{
var expr = exprList.Expressions[index];
if (index != 0 && exprList.Expressions[index - 1] is not ExprStatement)
{
this.Builder.Append(';');
}
expr.Accept(this, exprList);
}
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
protected bool VisitExprCastCommon(ExprCast exprCast, IExpr? parent)
{
this.Builder.Append("CAST(");
exprCast.Expression.Accept(this, exprCast);
this.Builder.Append(" AS ");
exprCast.SqlType.Accept(this, exprCast);
this.Builder.Append(')');
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
protected bool AcceptPar(char start, IExpr list, char end, IExpr? parent)
{
this.Builder.Append(start);
list.Accept(this, parent);
this.Builder.Append(end);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
internal bool AcceptListComaSeparatedPar(char start, IReadOnlyList<IExpr> list, char end, IExpr? parent)
{
this.Builder.Append(start);
this.AcceptListComaSeparated(list, parent);
this.Builder.Append(end);
return true;
}
19
View Source File : SqlBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
protected bool AcceptListComaSeparated(IReadOnlyList<IExpr> list, IExpr? parent)
{
for (int i = 0; i < list.Count; i++)
{
if (i != 0)
{
this.Builder.Append(',');
}
list[i].Accept(this, parent);
}
return true;
}
19
View Source File : SqlStatementBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
protected void AppendTable(StatementCreateTable statementCreateTable)
{
var table = statementCreateTable.Table;
this.Builder.Append("CREATE ");
this.AppendTempKeyword(table.FullName);
this.Builder.Append("TABLE ");
statementCreateTable.Table.FullName.Accept(this.ExprBuilder, null);
this.Builder.Append('(');
Columnreplacedysis replacedysis = Columnreplacedysis.Build();
for (int i = 0; i < table.Columns.Count; i++)
{
if (i != 0)
{
this.Builder.Append(',');
}
var column = table.Columns[i];
replacedysis.replacedyze(column);
this.AppendColumn(column: column);
}
this.AppendPkConstraints(table, replacedysis);
this.AppendFkConstraints(table, replacedysis);
this.AppendIndexesInside(table);
this.Builder.Append(')');
this.Builder.Append(';');
this.AppendIndexesOutside(table);
}
19
View Source File : SqlStatementBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
private void AppendPkConstraints(TableBase table, Columnreplacedysis replacedysis)
{
if (replacedysis.Pk.Count < 1)
{
return;
}
this.Builder.Append(",CONSTRAINT");
if (this.IsNamedPk())
{
this.Builder.Append(' ');
this.AppendName(this.BuildPkName(table.FullName));
}
this.Builder.Append(" PRIMARY KEY ");
this.ExprBuilder.AcceptListComaSeparatedPar('(', replacedysis.Pk, ')', null);
}
19
View Source File : SqlStatementBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
protected void AppendIndexColumnList(IndexMeta tableIndex)
{
tableIndex.Columns.replacedertNotEmpty("Table index has to contain at least one column");
this.Builder.Append('(');
for (var index = 0; index < tableIndex.Columns.Count; index++)
{
var column = tableIndex.Columns[index];
if (index != 0)
{
this.Builder.Append(',');
}
column.Column.ColumnName.Accept(this.ExprBuilder, null);
if (column.Descending)
{
this.Builder.Append(" DESC");
}
}
this.Builder.Append(')');
}
19
View Source File : SqlStatementBuilderBase.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
private string BuildFkName(IExprTableFullName tableIn, IExprTableFullName foreignTableIn)
{
StringBuilder nameBuilder = new StringBuilder();
ExprTableFullName table = tableIn.AsExprTableFullName();
ExprTableFullName foreignTable = foreignTableIn.AsExprTableFullName();
var schemaName = table.DbSchema != null ? this.Options.MapSchema(table.DbSchema.Schema.Name) + "_" : null;
nameBuilder.Append("FK_");
if (schemaName != null)
{
nameBuilder.Append(schemaName);
nameBuilder.Append('_');
}
nameBuilder.Append(table.TableName.Name);
nameBuilder.Append("_to_");
if (schemaName != null)
{
nameBuilder.Append(schemaName);
nameBuilder.Append('_');
}
nameBuilder.Append(foreignTable.TableName.Name);
return nameBuilder.ToString();
}
19
View Source File : SyntaxTreeOperationsTest.cs
License : MIT License
Project Creator : 0x1000000
License : MIT License
Project Creator : 0x1000000
[Test]
public void WalkThroughTest()
{
var tUser = Tables.User();
var tCustomer = Tables.Customer();
var e = Select(tUser.UserId, tUser.FirstName, tCustomer.CustomerId)
.From(tUser)
.InnerJoin(tCustomer, on: tCustomer.UserId == tUser.UserId)
.Done();
string expected = "0ExprQuerySpecification,1Int32TableColumn,2ExprTableAlias,3ExprAliasGuid," +
"2ExprColumnName,1StringTableColumn,2ExprTableAlias,3ExprAliasGuid," +
"2ExprColumnName,1Int32TableColumn,2ExprTableAlias,3ExprAliasGuid,2ExprColumnName," +
"1ExprJoinedTable,2User,3ExprTableFullName,4ExprDbSchema,5ExprSchemaName," +
"4ExprTableName,3ExprTableAlias,4ExprAliasGuid,2Customer,3ExprTableFullName," +
"4ExprDbSchema,5ExprSchemaName,4ExprTableName,3ExprTableAlias,4ExprAliasGuid," +
"2ExprBooleanEq,3NullableInt32TableColumn,4ExprTableAlias,5ExprAliasGuid," +
"4ExprColumnName,3Int32TableColumn,4ExprTableAlias,5ExprAliasGuid,4ExprColumnName,";
StringBuilder builder = new StringBuilder();
e.SyntaxTree().WalkThrough((expr, tier) =>
{
builder.Append(tier);
builder.Append(expr.GetType().Name);
builder.Append(',');
return VisitorResult<int>.Continue(tier+1);
}, 0);
replacedert.AreEqual(expected, builder.ToString());
}
19
View Source File : FourCC.cs
License : MIT License
Project Creator : 0xC0000054
License : MIT License
Project Creator : 0xC0000054
public override string ToString()
{
uint value = this.Value;
StringBuilder builder = new StringBuilder(20);
builder.Append('\'');
for (int i = 3; i >= 0; i--)
{
uint c = (value >> (i * 8)) & 0xff;
// Ignore any bytes that are not printable ASCII characters
// because they can not be displayed in the debugger watch windows.
if (c >= 0x20 && c <= 0x7e)
{
builder.Append((char)c);
}
}
builder.Append('\'');
builder.Append(" (0x").Append(value.ToString("X8")).Append(')');
return builder.ToString();
}
19
View Source File : FilenameProvider.cs
License : MIT License
Project Creator : 0xd4d
License : MIT License
Project Creator : 0xd4d
static string ReplaceInvalidFilenameChars(string candidate) {
var invalidChars = Path.GetInvalidFileNameChars();
if (candidate.IndexOfAny(invalidChars) < 0)
return candidate;
var sb = new System.Text.StringBuilder();
foreach (var c in candidate) {
if (Array.IndexOf(invalidChars, c) >= 0)
sb.Append('-');
else
sb.Append(c);
}
return sb.ToString();
}
See More Examples