本文整理汇总了C#中System.Text.StringBuilder.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.ToString方法的具体用法?C# StringBuilder.ToString怎么用?C# StringBuilder.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
/// <summary>
/// 运行JS代码
/// </summary>
/// <param name="Page">指定Page</param>
/// <param name="strCode">要注册的代码</param>
/// <param name="isTop">是否在头部/否则在尾部</param>
/// <param name="IDStr">Key</param>
public static void Run(System.Web.UI.Page Page, string strCode, bool isTop, string IDStr) {
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\">\n");
sb.Append(strCode.Trim());
sb.Append("\n</script>\n");
if (isTop) Page.RegisterClientScriptBlock(IDStr, sb.ToString()); else Page.RegisterStartupScript(IDStr, sb.ToString());
}
示例2: GetEdgesCsv
public IEnumerable<string> GetEdgesCsv(IEnumerable<OnergeDetay> onergeDetays)
{
// SOURCE_NODE_TYPE, SOURCE_NODE_NAME, EDGE_TYPE, TARGET_NODE_TYPE, TARGET_NODE_NAME, WEIGHT
var quote = "\"";
var nodes = new HashSet<string>();
int batchCount = 1;
var ret = new StringBuilder();
foreach (var detay in onergeDetays)
{
if (nodes.Count + 3 >= batchCount * 500)
{
yield return ret.ToString();
batchCount++;
ret.Clear();
}
ret.AppendFormat("{0}, {1}, {2}, {3}, {4}, {5}\n", "Milletvekili", detay.OnergeninSahibi, "UYE", "Parti", detay.Parti, 1);
ret.AppendFormat("{0}, {1}, {2}, {3}, {4}, {5}\n", "Milletvekili", detay.OnergeninSahibi, "SAHIP", "Soru Önergesi", detay.EsasNumarasi, 1);
ret.AppendFormat("{0}, {1}, {2}, {3}, {4}, {5}\n", "Soru Önergesi", quote + detay.EsasNumarasi + quote, "MUHATAP", "Bakan", quote + detay.OnergeninMuhatabi + quote, 1);
nodes.Add(detay.OnergeninSahibi);
nodes.Add(detay.Parti);
nodes.Add(detay.EsasNumarasi);
nodes.Add(detay.OnergeninMuhatabi);
}
yield return ret.ToString();
}
示例3: Wrap
public IEnumerable<string> Wrap(string input)
{
var builder = new StringBuilder();
int pos = 0;
var result = new List<string>();
foreach (var chr in input)
{
if (!(chr == ' ' && pos == 0))
{
builder.Append(chr);
++pos;
if (pos == rowLength)
{
result.Add(builder.ToString());
builder.Clear();
pos = 0;
}
}
}
if(builder.Length > 0)
result.Add(builder.ToString());
return result.AsReadOnly();
}
示例4: AssertValid
internal static void AssertValid(this DbDatabaseMapping databaseMapping, bool shouldThrow)
{
var storageItemMappingCollection = databaseMapping.ToStorageMappingItemCollection();
var errors = new List<EdmSchemaError>();
storageItemMappingCollection.GenerateViews(errors);
if (errors.Any())
{
var errorMessage = new StringBuilder();
errorMessage.AppendLine();
foreach (var error in errors)
{
errorMessage.AppendLine(error.ToString());
}
if (shouldThrow)
{
throw new MappingException(errorMessage.ToString());
}
Assert.True(false, errorMessage.ToString());
}
}
示例5: Delete_Click
/// <summary>
/// 删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Delete_Click(object sender, ImageClickEventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int i = 0; i < rpt_userinfo.Items.Count; i++)
{
CheckBox chk = rpt_userinfo.Items[i].FindControl("chkPro") as CheckBox;
if (chk.Checked)
{
HiddenField hidd = rpt_userinfo.Items[i].FindControl("hiddId") as HiddenField;
sb.Append(hidd.Value + ",");
}
}
if (sb.Length == 0)
{
ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "alert('您没有选择任何项');", true);
return;
}
else
{
try
{
UserManageBLL.Delete(sb.ToString().Substring(0,sb.ToString().Length-1));
LoadDataBind(strWhere);
}
catch
{
ScriptManager.RegisterStartupScript(Page, typeof(Page), "ListArea", "alert('出现错误!请重新尝试!');", true);
}
}
}
示例6: btnUpload_Click
protected void btnUpload_Click(object sender, EventArgs e)
{
M_InfoModel info = InfoModelBll.GetModel(2);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
int maxWidth = Function.CheckNumber(txtMaxWidth.Text) == true ? int.Parse(txtMaxWidth.Text) : 0;
int maxHeight = Function.CheckNumber(txtMaxHeight.Text) == true ? int.Parse(txtMaxHeight.Text) : 0;
int bili = Function.CheckNumber(txtBili.Text) == true ? int.Parse(txtBili.Text) : 0;
for (int i = 1; i < 13; i++)
{
HtmlInputFile file = Page.FindControl("File" + i) as HtmlInputFile;
if (file.PostedFile != null && file.PostedFile.FileName != "")
{
B_UpLoadPic up = new B_UpLoadPic();
string imgName = up.GetUpLoadPicPath(file, picSavePath, IsWatermark.Checked, IsNewSize.Checked, maxWidth, maxHeight, IsBiLi.Checked, bili,info.UploadSize);
sb.Append(imgName);
sb.Append(",");
}
}
//返回文件名
if (sb.ToString() == "")
{
LitMsg.Text = "<script type='text/javascript'>alert('未上传任何图片')</script>";
return;
}
else
{
imgNames.Text = sb.ToString();
btnReturnValue.Visible = true;
btnUpload.Visible = false;
}
}
示例7: RunInternal
private string RunInternal(string arguments, string fileName)
{
StringBuilder result = new StringBuilder();
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = Path.Combine(typeof(MediaConvertor).Assembly.GetAssemblyDirectory(), string.Format(@"AVConv\{0}", fileName));
startInfo.Arguments = arguments;
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
process.StartInfo = startInfo;
process.ErrorDataReceived += (sender, args) => Common.Log.Error("Error during video converion: '{0}'", args.Data);
process.OutputDataReceived += (sender, args) => Common.Log.Debug("Video converting: {0}", args.Data);
process.Start();
while (!process.StandardError.EndOfStream)
{
string line = process.StandardError.ReadLine();
result.AppendLine(line);
Common.Log.Debug("Video converting: {0}", line);
}
process.WaitForExit();
if (process.ExitCode != 0)
throw new AvConvException("File converion failed", result.ToString());
return result.ToString();
}
示例8: GetEditProblemViewModel
public static EditProblemViewModel GetEditProblemViewModel(Problem problem)
{
var epvm = new EditProblemViewModel();
epvm.Author = problem.Author.UserName;
epvm.Name = problem.Name;
epvm.Text = problem.Text;
epvm.SelectedCategoryId = problem.CategoryId;
epvm.IsBlocked = problem.IsBlocked;
var sb = new StringBuilder();
foreach (var tag in problem.Tags)
{
sb.Append(tag.Name);
sb.Append(',');
}
epvm.TagsString = sb.ToString();
sb.Clear();
foreach (var ans in problem.CorrectAnswers)
{
sb.Append(ans.Text);
sb.Append(';');
}
sb.Remove(sb.Length - 1, 1);
epvm.Answers = sb.ToString();
return epvm;
}
示例9: BuildMessage
public string BuildMessage(List<JiraModel> sameJiraIssueKeyEvents)
{
var stringBuilder = new StringBuilder();
var firstEvent = sameJiraIssueKeyEvents.First();
if (CreatedIssueThenUpdated(sameJiraIssueKeyEvents, firstEvent))
{
BuildIssueCreatedMessage(firstEvent, stringBuilder);
return stringBuilder.ToString();
}
if (OnlyUpdatedIssue(sameJiraIssueKeyEvents))
{
BuildChangeLogMessage(sameJiraIssueKeyEvents.Last(), stringBuilder);
return stringBuilder.ToString();
}
switch (firstEvent.webhookEvent)
{
case "jira:issue_created":
BuildIssueCreatedMessage(firstEvent, stringBuilder);
break;
case "jira:issue_updated":
BuildChangeLogMessage(firstEvent, stringBuilder);
break;
}
return stringBuilder.ToString();
}
示例10: ExecuteTask
protected override void ExecuteTask()
{
//Check the file exists
string docPath = Project.ExpandProperties(_xmldoc, Location).Replace(@"file:\", "");
if (!File.Exists(docPath))
{
throw new BuildException("The xml document specified does not exist");
}
// Load the document and run the selection
XmlDocument doc = new XmlDocument();
doc.Load(docPath);
XmlNodeList list = doc.SelectNodes(_selection);
Project.Log(Level.Info, "Found " + list.Count.ToString() + " nodes");
StringBuilder builder = new StringBuilder();
foreach (XmlNode node in list)
{
builder.Append(node.InnerText);
builder.Append(",");
}
if (builder.Length > 0)
{
builder.Length -= 1;
}
if (Project.Properties.Contains(_property))
{
Project.Properties[_property] = builder.ToString();
}
else
{
Project.Properties.Add(_property, builder.ToString());
}
}
示例11: Zap
/// <summary>
/// Execute any update statements required to clear data, followed by delete statements for all tables.
/// </summary>
/// <param name="updateCommands">Update commands to execute</param>
/// <param name="tables">Tables to delete from</param>
/// <param name="timeout">Maximum time for a statement</param>
/// <param name="deleteBatch">Batch delete statements into groups, saves times on databases with large numbers of tables.</param>
public void Zap(IEnumerable<string> updateCommands, IEnumerable<string> tables, int timeout = 30, int deleteBatch = 1)
{
foreach (var item in updateCommands)
{
dao.ExecuteNonQuery(item, timeout);
}
var sb = new StringBuilder();
var count = 0;
foreach (var item in tables)
{
sb.AppendLine(string.Format("DELETE FROM {0};", item));
count++;
if (count % deleteBatch != 0)
{
continue;
}
dao.ExecuteNonQuery(sb.ToString(), timeout);
sb.Clear();
}
var lastCmd = sb.ToString();
if (!string.IsNullOrEmpty(lastCmd))
{
dao.ExecuteNonQuery(lastCmd, timeout);
}
}
示例12: Add
public void Add(ITraceEvent traceEvent)
{
var message = new StringBuilder();
if (HttpContext.Current != null)
{
message.Append("During HTTP request to: ");
message.Append(HttpContext.Current.Request.Url);
message.AppendLine();
}
message.Append("Instance ");
message.Append(traceEvent.Source.TraceId);
message.Append(" of type ");
message.Append(traceEvent.Source.GetType());
message.Append(" reported: ");
message.Append(traceEvent.Message);
message.AppendLine();
if (traceEvent.IsError)
{
log.Error(message.ToString());
}
else
{
log.Debug(message.ToString());
}
}
示例13: GetImageFromCache
public Image GetImageFromCache(GMapType type, Point pos, int zoom, string language)
{
Image ret = null;
try
{
StringBuilder dir = new StringBuilder(tileCache);
dir.AppendFormat("{0}{1}{2}{3}{4}{5}{6}{7}", zoom, Path.DirectorySeparatorChar, language, Path.DirectorySeparatorChar, pos.X, Path.DirectorySeparatorChar, pos.Y, Path.DirectorySeparatorChar);
{
dir.AppendFormat("{0}.png", type.ToString());
}
if(File.Exists(dir.ToString()))
{
FileInfo f = new FileInfo(dir.ToString());
if(f.Length == 0)
{
f.Delete();
}
else
{
using(FileStream s = f.Open(FileMode.Open, FileAccess.Read, FileShare.Read))
{
ret = Image.FromStream(s);
s.Close();
}
}
}
}
catch
{
ret = null;
}
return ret;
}
示例14: ParseProperties
private static IDictionary<string, string> ParseProperties(IEnumerable<Symbol> header)
{
IDictionary<string, string> result = new Dictionary<string, string>();
StringBuilder data = new StringBuilder();
string previous = string.Empty;
foreach (Symbol sym in header)
{
if (IsProperty(sym))
{
if (previous != null)
{
result.Add(previous, data.ToString());
}
previous = sym.ToString();
data.Length = 0;
continue;
}
if (sym == Symbol.Assign)
{
break;
}
data.Append(sym.ToString());
}
if (previous != null)
{
result.Add(previous, data.ToString());
}
return result;
}
示例15: Describe
public static string Describe(this IColorSwitchState state)
{
var result = new StringBuilder();
if (state == null)
{
return result.ToString();
}
if (state.Value == null)
{
result.Append("Unknown Color");
}
else
{
var color = state.Value;
result.Append(color.ToHexString());
var name = color.Name;
if (name != null && name.Value != null)
{
result.Append("(");
result.Append(name.Value);
result.Append(")");
}
}
return result.ToString();
}