本文整理汇总了C#中System.Text.StringBuilder.Push方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.Push方法的具体用法?C# StringBuilder.Push怎么用?C# StringBuilder.Push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.Push方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPush
public void TestPush() {
var expected = "GM250";
var test = "250GM";
var sb = new StringBuilder(test);
sb.Push(char.IsNumber);
var actual = sb.ToString();
Assert.AreEqual(expected, actual);
}
示例2: Render
/// <summary>
/// Renders the required JavaScript onto the page for Google Analytics tracking.
/// Recommended to include this within the head element of the page.
/// </summary>
public static IHtmlString Render()
{
var gaq = new StringBuilder(Scripts.ScriptStart);
gaq.Push(string.Format(Scripts.SetAccount, Account));
// Events
foreach (var gaEvent in Current.Events)
gaq.Push(Scripts.TrackEvent.FormatWith(gaEvent));
// Social
foreach (var socialEvent in Current.SocialEvents)
gaq.Push(string.IsNullOrWhiteSpace(socialEvent.PagePath)
? Scripts.TrackSocial.FormatWith(socialEvent)
: Scripts.TrackSocialWithPagePath.FormatWith(socialEvent));
// Transaction
if (Current.Transactions.Any())
foreach (var trans in Current.Transactions)
gaq.Push(Scripts.AddTrans.FormatWith(trans));
// Items
if (Current.Items.Any())
foreach (var item in Current.Items)
gaq.Push(Scripts.AddItem.FormatWith(item));
// Page view
gaq.Push(string.IsNullOrWhiteSpace(Current.VirtualPageUrl)
? Scripts.TrackPageView
: string.Format(Scripts.TrackVirtualPageView, Current.VirtualPageUrl.TrimStart('/')));
// Track transaction
if (Current.Transactions.Any())
gaq.Push(Scripts.TrackTrans);
gaq.AppendLine(Scripts.ScriptEnd);
return new HtmlString(gaq.ToString());
}