本文整理汇总了C#中System.Text.StringBuilder.Replace方法的典型用法代码示例。如果您正苦于以下问题:C# System.Text.StringBuilder.Replace方法的具体用法?C# System.Text.StringBuilder.Replace怎么用?C# System.Text.StringBuilder.Replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.StringBuilder
的用法示例。
在下文中一共展示了System.Text.StringBuilder.Replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FixBase64ForImage
public static string FixBase64ForImage(string Image)
{
System.Text.StringBuilder sbText = new System.Text.StringBuilder(Image, Image.Length);
sbText.Replace("\r\n", string.Empty);
sbText.Replace(" ", string.Empty);
return sbText.ToString();
}
示例2: XMLEncode
static public string XMLEncode(string i_String)
{
System.Text.StringBuilder StringBuilder = new System.Text.StringBuilder(i_String);
StringBuilder = StringBuilder.Replace("&", "&");
StringBuilder = StringBuilder.Replace(">", ">");
StringBuilder = StringBuilder.Replace("<", "<");
StringBuilder = StringBuilder.Replace("\"", """);
StringBuilder = StringBuilder.Replace("'", "'");
return StringBuilder.ToString();
}
示例3: BuildPrinterImage
protected string BuildPrinterImage(bool BeenProcessed, int RequestId, string EnabledImage, string DisabledImage)
{
System.Text.StringBuilder html = new System.Text.StringBuilder(string.Empty);
if (BeenProcessed)
{
html.Append("<a href='%url%?rid=%id%' title='Print prayer request' target='_blank'><img src='/Images/%imgurl%' alt='X' style='border: none;width: 16px; height: 16px;' /></a>");
html.Replace("%url%", "PrayerRequestPrint.aspx");
html.Replace("%id%", RequestId.ToString());
html.Replace("%imgurl%", EnabledImage);
}
else
{
html.Append("<a href='' title='The request must be assigned to someone before printing'><img src='/Images/%imgurl%' alt='X' style='border: none;width: 16px; height: 16px;' /></a>");
html.Replace("%imgurl%", DisabledImage);
}
return html.ToString();
}
示例4: ReplaceSpecialTemplate
/// <summary>
/// 解析特殊变量
/// </summary>
/// <param name="forumPath">模板路径</param>
/// <param name="skinName">皮肤名</param>
/// <param name="strTemplate">模板内容</param>
/// <returns></returns>
public override string ReplaceSpecialTemplate(string forumPath,string skinName,string strTemplate)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(strTemplate);
Match m;
Regex r = new Regex(@"({([^\[\]/\{\}='\s]+)})", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Compiled);
for (m = r.Match(strTemplate); m.Success; m = m.NextMatch())
{
if (m.Groups[0].ToString() == "{forumversion}")
sb = sb.Replace(m.Groups[0].ToString(), Utils.GetAssemblyVersion());
else if (m.Groups[0].ToString() == "{forumproductname}")
sb = sb.Replace(m.Groups[0].ToString(), Utils.GetAssemblyProductName());
}
foreach(DataRow dr in GetTemplateVarList(forumPath,skinName).Rows)
{
sb = sb.Replace(dr["variablename"].ToString().Trim(), dr["variablevalue"].ToString().Trim());
}
return sb.ToString();
}
示例5: ApplicationErrorMail
//Function for ApplicationErrorMail
/// <summary>
/// Function for ApplicationErrorMail
/// </summary>
public static bool ApplicationErrorMail(string ErrorDetails)
{
MailTemplate template = new MailTemplate(MailTemplate.Templates.ApplicationError);
//fetch subject and contents
string Subject = template.Subject;
System.Text.StringBuilder Body = new System.Text.StringBuilder(template.Body);
//set contents
Body = Body.Replace("[ERRORDETAILS]", ErrorDetails);
//send email
return Send(ConfigureApplicationErrorMail(ErrorDetails, new MailMessage()));
}
示例6: StripAccents
private string StripAccents(string input)
{
string beforeConversion = "àÀâÂäÄáÁéÉèÈêÊëËìÌîÎïÏòÒôÔöÖùÙûÛüÜçÇ’ñ";
string afterConversion = "aAaAaAaAeEeEeEeEiIiIiIoOoOoOuUuUuUcC'n";
System.Text.StringBuilder sb = new System.Text.StringBuilder(input);
for (int i = 0; i < beforeConversion.Length; i++)
{
char beforeChar = beforeConversion[i];
char afterChar = afterConversion[i];
sb.Replace(beforeChar, afterChar);
}
sb.Replace("œ", "oe");
sb.Replace("Æ", "ae");
return sb.ToString();
}
示例7: BuildResponseImage
protected string BuildResponseImage(bool BeenProcessed, int RequestId, int ResponseId, string EnabledImageOn, string EnabledImageOff, string DisabledImage)
{
System.Text.StringBuilder html = new System.Text.StringBuilder(string.Empty);
if (BeenProcessed)
{
string img = (ResponseId > 0) ? EnabledImageOn : EnabledImageOff;
html.Append("<a href='%url%?rid=%id%' title='Respond to prayer'><img src='/Images/%imgurl%' alt='X' style='border: none;width: 16px; height: 16px;' /></a>");
html.Replace("%url%", "PrayerResponse.aspx");
html.Replace("%id%", RequestId.ToString());
html.Replace("%imgurl%", img);
}
else
{
html.Append("<a href='' title='The request must be assigned to someone before responding.'><img src='/Images/%imgurl%' alt='X' style='border: none;width: 16px; height: 16px;' /></a>");
html.Replace("%imgurl%", DisabledImage);
}
return html.ToString();
}
示例8: DoubleNumbers
static string DoubleNumbers(string str)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(str);
for (var i = 0; i < str.Length; i++)
{
if( Char.IsNumber( str[ i ] ) )
{
sb.Replace(str[i].ToString(), str[i].ToString() + str[i].ToString());
}
}
return sb.ToString();
}
示例9: ProcessBigString
string ProcessBigString( StringBuilder builder )
{
// handle escaped >
builder.Replace( @"\>", ">" );
// kill first newline
int trimStart = 0;
if ( builder.Length > 0 )
{
switch ( builder[0] )
{
case '\r':
if ( builder.Length > 1 && builder[1] == '\n' )
trimStart = 2;
else
trimStart = 1;
break;
case '\n':
trimStart = 1;
break;
default:
break;
}
}
// kill last newline
int trimEnd = 0;
if ( builder.Length > trimStart )
{
switch ( builder[builder.Length - 1] )
{
case '\r':
trimEnd = 1;
break;
case '\n':
if ( builder[builder.Length - 2] == '\r' )
trimEnd = 2;
else
trimEnd = 1;
break;
default:
break;
}
}
return builder.ToString( trimStart, builder.Length - trimStart - trimEnd );
}
示例10: ParseFromXml
public AnimeResultContainer ParseFromXml(string xml)
{
var sb = new System.Text.StringBuilder();
sb.Append(xml);
sb.Replace("<title>", "<title><![CDATA[");
sb.Replace("</title>", "]]></title>");
sb.Replace("<english>", "<english><![CDATA[");
sb.Replace("</english>", "]]></english>");
sb.Replace("<synonyms>", "<synonyms><![CDATA[");
sb.Replace("</synonyms>", "]]></synonyms>");
sb.Replace("<synopsis>", "<synopsis><![CDATA[");
sb.Replace("</synopsis>", "]]></synopsis>");
return _xmlSerializerAndDeserializer.ConvertFromXml<AnimeResultContainer>(sb.ToString());
}
示例11: BuildPagedSelectStatement
/// <summary>
/// Builds the paged select statement.
/// </summary>
/// <returns></returns>
public override string BuildPagedSelectStatement()
{
int startnum = query.PageSize * query.CurrentPage + 1;
int endnum = query.PageSize * query.CurrentPage + query.PageSize;
string orderBy = String.Empty;
if (this.query.OrderBys.Count > 0)
orderBy = GenerateOrderBy();
//The ROW_NUMBER() function in Oracle requires an ORDER BY clause.
//In case one is not specified, we need to halt and inform the caller.
if(orderBy.Equals(String.Empty))
throw new ArgumentException("There is no column specified for the ORDER BY clause", "OrderBys");
System.Text.StringBuilder sql = new System.Text.StringBuilder();
//Build the command string
sql.Append("WITH pagedtable AS (");
sql.Append(GenerateCommandLine());
//Since this class is for Oracle-specific SQL, we can add a hint
//which should help pagination queries return rows more quickly.
//AFAIK, this is only valid for Oracle 9i or newer.
sql.Replace("SELECT", "SELECT /*+ first_rows('" + query.PageSize + "') */");
sql.Append(", ROW_NUMBER () OVER (");
sql.Append(orderBy);
sql.Append(") AS rowindex ");
sql.Append(Environment.NewLine);
sql.Append(GenerateFromList());
sql.Append(GenerateJoins());
sql.Append(GenerateWhere());
if (query.Aggregates.Count > 0)
{
sql.Append(GenerateGroupBy());
sql.Append(Environment.NewLine);
sql.Append(GenerateHaving());
}
sql.Append(") SELECT * FROM pagedtable WHERE rowindex BETWEEN ");
sql.Append(startnum);
sql.Append(" AND ");
sql.Append(endnum);
sql.Append(" ORDER BY rowindex");
return sql.ToString();
}
示例12: ConfigureApplicationErrorMail
// Special case function for ELMAH (only configure email)
/// <summary>
/// Configure email
/// </summary>
/// <param name="ErrorDetails">Error details</param>
/// <param name="mailMsg">MailMessage to configure</param>
/// <returns>MailMessage</returns>
public static MailMessage ConfigureApplicationErrorMail(string ErrorDetails, MailMessage mailMsg, string physicalApplicationPath = "")
{
MailTemplate template = new MailTemplate(MailTemplate.Templates.ApplicationError, physicalApplicationPath);
//fetch subject and contents
string Subject = template.Subject;
System.Text.StringBuilder Body = new System.Text.StringBuilder(template.Body);
//set contents
Body = Body.Replace("[ERRORDETAILS]", ErrorDetails);
//configure email
mailMsg.From = new MailAddress(Config.ContactEmail);
mailMsg.To.Clear(); // Provide comma sep as per - http://msdn.microsoft.com/en-us/library/ms144695.aspx
mailMsg.To.Add(Config.ApplicationErrorEmail);
mailMsg.Subject = Subject;
mailMsg.Body = Body.ToString() + mailMsg.Body; // Prepand our dody info
return mailMsg;
}
示例13: AssignToMail
//Function to send claim comment mail
/// <summary>
/// Function to send Assign To change claim email
/// </summary>
/// <param name="Comment">Claim comment</param>
/// <param name="ClaimId">Claim Id</param>
/// <param name="AssignToEmail">Email of the user to whom the Claim has been Assigned</param>
/// <returns>True if sent</returns>
public static bool AssignToMail(string ClaimNo, string Comment, int ClaimId, string AssignToEmail, string Assigner, bool FromComment)
{
MailTemplate template = new MailTemplate(MailTemplate.Templates.ClaimAssignTo);
//fetch subject and contents
string Subject = template.Subject.Replace("[CLAIM#]", ClaimNo);
System.Text.StringBuilder Body = new System.Text.StringBuilder(template.Body);
//set contents
string claimLink = //FromComment ? Defaults.trimLastURLSegment(HttpContext.Current.Request.Url.ToString()) : HttpContext.Current.Request.Url.ToString();
HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) +
new System.Web.Mvc.UrlHelper(HttpContext.Current.Request.RequestContext).Action("Manage?", "Claim", new { ClaimID = ClaimId });
claimLink = System.Web.HttpUtility.UrlDecode(claimLink);//.TrimEnd(new char[] { '?' });//Need to add Manage? so that mvc doesn't remove default action, now trim it.
Body = Body.Replace("[CLAIM#]", ClaimNo).Replace("[ASSIGNER]", Assigner).Replace("[COMMENT]", Comment).Replace("[LINK]", claimLink);
//send email
return Send(ConfigureMailMessage(Config.ContactEmail, AssignToEmail, Body.ToString(), Subject, ""));
}
示例14: warning
public void warning(string message)
{
System.Text.StringBuilder s = new System.Text.StringBuilder("-! ");
s.Append(System.DateTime.Now.ToString(_date, CultureInfo.CurrentCulture));
s.Append(' ');
s.Append(System.DateTime.Now.ToString(_time, CultureInfo.CurrentCulture));
s.Append(' ');
s.Append(_prefix);
s.Append("warning: ");
s.Append(message);
s.Replace("\n", "\n ");
lock(_globalMutex)
{
write(s.ToString());
}
}
示例15: trace
public void trace(string category, string message)
{
System.Text.StringBuilder s = new System.Text.StringBuilder("-- ");
s.Append(System.DateTime.Now.ToString(_date, CultureInfo.CurrentCulture));
s.Append(' ');
s.Append(System.DateTime.Now.ToString(_time, CultureInfo.CurrentCulture));
s.Append(' ');
s.Append(_formattedPrefix);
s.Append(category);
s.Append(": ");
s.Append(message);
s.Replace("\n", "\n ");
lock(_globalMutex)
{
write(s.ToString());
}
}