本文整理匯總了C#中System.IO.StringWriter.Tag方法的典型用法代碼示例。如果您正苦於以下問題:C# StringWriter.Tag方法的具體用法?C# StringWriter.Tag怎麽用?C# StringWriter.Tag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.IO.StringWriter
的用法示例。
在下文中一共展示了StringWriter.Tag方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetReport
public string GetReport()
{
ComputeStats();
var w = new StringWriter();
using (w.Tag("table"))
{
w.WriteLine("<tr><td>benchmark</td><td colspan={0}>runs</td><td>relative</td><td>ops / second</tr>".Formatted(operationruns.First().Value.Runs.Count));
foreach (var run in this.operationruns)
{
w.WriteLine("<tr><td>{0}</td>{1}<td>{2}</td><td>{3}</td></tr>".Formatted(
run.Key,
run.Value.Runs.Select(r => "<td align=right>{0}</td>".Formatted(r.ExecutionTime.TotalMilliseconds.ToString("0.00"))).Joined(),
"<div class='bar' style='width:{0}px'> </div>".Formatted(run.Value.RelativeExecutionTimePercent),
run.Value.AverageOperationsPerSeconds(this.N).ToString("#,##0")
));
}
}
w.WriteLine();
using (w.Tag("table"))
{
w.TableRow("computer specs");
var spec = new ComputerSpecs();
foreach (FieldInfo field in spec.GetType().GetFields())
{
w.TableRow(field.Name, field.GetValue(spec) as string);
}
}
string html = File.ReadAllText("results.htm");
html = html.Replace("results", w.ToString());
return html;
}