本文整理匯總了C#中System.Text.StringBuilder.Append方法的典型用法代碼示例。如果您正苦於以下問題:C# StringBuilder.Append方法的具體用法?C# StringBuilder.Append怎麽用?C# StringBuilder.Append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Text.StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.Append方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Replace
public string Replace (string str)
{
if (string.IsNullOrEmpty (str)) {
return str;
}
System.Text.StringBuilder formatted = new System.Text.StringBuilder ();
int lastMatch = 0;
string variable;
string replacement;
foreach (System.Text.RegularExpressions.Match m in re.Matches(str)) {
formatted.Append (str.Substring (lastMatch, m.Index - lastMatch));
variable = m.Groups [1].Value;
if (vars.TryGetValue (variable, out replacement))
formatted.Append (this.Replace (replacement));
else
throw new ObfuscarException("Unable to replace variable: " + variable);
lastMatch = m.Index + m.Length;
}
formatted.Append (str.Substring (lastMatch));
return formatted.ToString ();
}
示例2: Inserir
/// <exception cref="MyException"></exception>
public void Inserir(ICliente cliente, ILog log)
{
var sql = new StringBuilder();
var tblLog = new TblClientesLog();
sql.AppendFormat(" INSERT INTO {0} ({1},{2},{3}", tblLog.NomeTabela, tblLog.Clientes_Id, tblLog.Clientes_Nome, tblLog.Clientes_Status_Id);
sql.AppendFormat(",{0},{1},{2})", tblLog.Usuarios_Id, tblLog.Operacao_Id, tblLog.DataHora);
sql.Append(" VALUES (@id,@nome,@status_id");
sql.Append(",@usuarios_id,@operacao_id,@datahora);");
using (var dal = new DalHelperSqlServer())
{
try
{
dal.CriarParametroDeEntrada("id", SqlDbType.Int, cliente.Id);
dal.CriarParametroDeEntrada("nome", SqlDbType.Char, cliente.Nome);
dal.CriarParametroDeEntrada("status_id", SqlDbType.SmallInt, cliente.Status.GetHashCode());
dal.CriarParametroDeEntrada("usuarios_id", SqlDbType.Int, log.Usuario.Id);
dal.CriarParametroDeEntrada("operacao_id", SqlDbType.SmallInt, log.Operacao.GetHashCode());
dal.CriarParametroDeEntrada("datahora", SqlDbType.DateTime, log.DataHora);
dal.ExecuteNonQuery(sql.ToString());
}
catch (SqlException) { throw new MyException("Operação não realizada, por favor, tente novamente!"); }
}
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
ReciboBE reciboBE;
//if (Session["ReciboBE"] != null)
//{
reciboBE = Session["ReciboBE"] as ReciboBE;
//}
CarregaProfissional(Convert.ToInt32(reciboBE.RefProfissionalBE.id));
lblReciboNumero.Text = Convert.ToString(reciboBE.id);
lblValorTotalCabecalho.Text = String.Format("{0:C2}", reciboBE.ValorTotal);
lblValorTotal.Text = String.Format("{0:C2}", reciboBE.ValorTotal);
lblSessoesQtd.Text = Convert.ToString(reciboBE.RefReciboAgendamentoSessoesBE.Count.ToString("00"));
lblPacienteNome.Text = Convert.ToString(reciboBE.PacienteNome);
//Pego a possicao zero da lista de sessooes
lblValorSessao.Text = String.Format("{0:C2}", reciboBE.RefReciboAgendamentoSessoesBE[0].Valor);
StringBuilder sb = new System.Text.StringBuilder();
for (int i = 0; i < reciboBE.RefReciboAgendamentoSessoesBE.Count; i++)
{
if (i > 0)
sb.Append(", ");
sb.Append(reciboBE.RefReciboAgendamentoSessoesBE[i].Data.ToString("dd/MM/yyyy"));
}
lblDatas.Text = Convert.ToString(sb);
DataExtenso();
}
示例4: AsText
public override void AsText(StringBuilder b, int pad)
{
b.Append(' ', pad);
b.AppendLine("JewelerDataInitialMessage:");
b.Append(' ', pad++);
b.Append(CrafterData.ToString());
}
示例5: FormatCommentOn
protected virtual string FormatCommentOn(string sql)
{
StringBuilder result = new StringBuilder(60).Append(Indent1);
IEnumerator<string> tokens = (new StringTokenizer(sql, " '[]\"", true)).GetEnumerator();
bool quoted = false;
while (tokens.MoveNext())
{
string token = tokens.Current;
result.Append(token);
if (IsQuote(token))
{
quoted = !quoted;
}
else if (!quoted)
{
if ("is".Equals(token))
{
result.Append(Indent2);
}
}
}
return result.ToString();
}
示例6: FormatAlterTable
protected virtual string FormatAlterTable(string sql)
{
StringBuilder result = new StringBuilder(60).Append(Indent1);
IEnumerator<string> tokens = (new StringTokenizer(sql, " (,)'[]\"", true)).GetEnumerator();
bool quoted = false;
while (tokens.MoveNext())
{
string token = tokens.Current;
if (IsQuote(token))
{
quoted = !quoted;
}
else if (!quoted)
{
if (IsBreak(token))
{
result.Append(Indent3);
}
}
result.Append(token);
}
return result.ToString();
}
示例7: AsEsql
internal override StringBuilder AsEsql(StringBuilder builder, bool isTopLevel, int indentLevel)
{
// The SELECT/DISTINCT part.
StringUtil.IndentNewLine(builder, indentLevel);
builder.Append("SELECT ");
if (m_selectDistinct == CellQuery.SelectDistinct.Yes)
{
builder.Append("DISTINCT ");
}
GenerateProjectionEsql(builder, m_nodeTableAlias, true, indentLevel, isTopLevel);
// Get the FROM part.
builder.Append("FROM ");
CqlWriter.AppendEscapedQualifiedName(builder, m_extent.EntityContainer.Name, m_extent.Name);
builder.Append(" AS ").Append(m_nodeTableAlias);
// Get the WHERE part only when the expression is not simply TRUE.
if (!BoolExpression.EqualityComparer.Equals(WhereClause, BoolExpression.True))
{
StringUtil.IndentNewLine(builder, indentLevel);
builder.Append("WHERE ");
WhereClause.AsEsql(builder, m_nodeTableAlias);
}
return builder;
}
示例8: MediaHelper
public static object MediaHelper(string image)
{
var sb = new StringBuilder();
sb.Append(ConfigurationManager.AppSettings["MediaPath"]);
sb.Append(image);
return new MvcHtmlString(sb.ToString());
}
示例9: AsNegatedUserString
internal override StringBuilder AsNegatedUserString(StringBuilder builder, string blockAlias, bool skipIsNotNull)
{
builder.Append("NOT(");
builder = AsUserString(builder, blockAlias, skipIsNotNull);
builder.Append(")");
return builder;
}
示例10: ToCsv
public static string ToCsv(this DataTable dataTable)
{
var sbData = new StringBuilder();
// Only return Null if there is no structure.
if (dataTable.Columns.Count == 0)
return null;
foreach (var col in dataTable.Columns)
{
if (col == null)
sbData.Append(",");
else
sbData.Append("\"" + col.ToString().Replace("\"", "\"\"") + "\",");
}
sbData.Replace(",", System.Environment.NewLine, sbData.Length - 1, 1);
foreach (DataRow dr in dataTable.Rows)
{
foreach (var column in dr.ItemArray)
{
if (column == null)
sbData.Append(",");
else
sbData.Append("\"" + column.ToString().Replace("\"", "\"\"") + "\",");
}
sbData.Replace(",", System.Environment.NewLine, sbData.Length - 1, 1);
}
return sbData.ToString();
}
示例11: ToString
public override string ToString() {
if (invariant) {
if (invariant_result)
return "PivotsExpression.TrueExpression";
else
return "PivotsExpression.FalseExpression";
}
StringBuilder res = new StringBuilder();
bool first_combination = true;
foreach (var combination in matching_combinations) {
if (!first_combination)
res.Append("|");
res.Append("(");
bool first_value = true;
foreach (var item in combination) {
if (!first_value)
res.Append(",");
res.Append(item);
first_value = false;
}
res.Append(")");
first_combination = false;
}
return res.ToString();
}
示例12: Write
public override void Write(StringBuilder builder, int index)
{
if (index > 0)
builder.Append('.');
builder.Append(property);
}
示例13: Process
/// <summary>
/// Processes the specified arguments.
/// </summary>
/// <param name="args">The arguments.</param>
public virtual void Process(PipelineArgs args)
{
Assert.ArgumentNotNull(args, "args");
ShoppingCart shoppingCart = Context.Entity.GetInstance<ShoppingCart>();
PaymentProvider paymentProvider = Context.Entity.Resolve<PaymentProvider>(shoppingCart.PaymentSystem.Code);
PaymentUrlResolver paymentUrlResolver = new PaymentUrlResolver();
PaymentArgs paymentArgs = new PaymentArgs
{
ShoppingCart = shoppingCart,
PaymentUrls = paymentUrlResolver.Resolve(),
};
StringBuilder description = new StringBuilder();
foreach (ShoppingCartLine shoppingCartLine in shoppingCart.ShoppingCartLines)
{
description.Append(shoppingCartLine.Product.Title);
description.Append(", ");
}
paymentArgs.Description = description.ToString().Trim().TrimEnd(',');
paymentProvider.Invoke(shoppingCart.PaymentSystem, paymentArgs);
args.AbortPipeline();
}
示例14: CanReadCompleContent
public void CanReadCompleContent()
{
// Arrange
var content = "This is";
var sb = new StringBuilder();
var sr = new StreamReader(content.ToStream());
var lab = new CharBuffer(() =>
{
int read = sr.Read();
return read != -1 ? new char?((char)read) : new char?();
}, 3);
// Act
while (lab.HasNext())
{
sb.Append(lab.PeekAt(0));
lab.Consume();
}
sb.Append(lab.PeekAt(0));
// Assert
sb.ToString().Should().Be(content);
}
示例15: Get2000
private static string Get2000()
{
StringBuilder sql = new StringBuilder();
sql.Append("SELECT groupname as name, convert(int,groupid) AS [ID],is_default=convert(bit,status & 16),is_read_only=convert(bit,status & 8),'FG' as type ");
sql.Append("FROM sysfilegroups ORDER BY groupname");
return sql.ToString();
}