本文整理汇总了C#中LogEntry.Reverse方法的典型用法代码示例。如果您正苦于以下问题:C# LogEntry.Reverse方法的具体用法?C# LogEntry.Reverse怎么用?C# LogEntry.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogEntry
的用法示例。
在下文中一共展示了LogEntry.Reverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildLogTable
private void BuildLogTable(LogEntry[] entries)
{
XElement table = new XElement("table");
XElement tableHeader = new XElement("tr");
tableHeader.Add(
new XElement("th", " "),
new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.DateLabel")),
new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.MessageLabel")),
new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.TitleLabel")),
new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.EventTypeLabel"))
//new XElement("th", "URL"),
//new XElement("th", "Referer")
);
table.Add(tableHeader);
foreach (LogEntry logEntry in entries.Reverse())
{
TraceEventType eventType;
try
{
eventType = (TraceEventType)Enum.Parse(typeof(TraceEventType), logEntry.Severity);
}
catch (Exception)
{
eventType = TraceEventType.Information;
}
XAttribute color = null;
switch (eventType)
{
case TraceEventType.Information:
color = new XAttribute("bgcolor", "lime");
break;
case TraceEventType.Verbose:
color = new XAttribute("bgcolor", "white");
break;
case TraceEventType.Warning:
color = new XAttribute("bgcolor", "yellow");
break;
case TraceEventType.Error:
color = new XAttribute("bgcolor", "orange");
break;
case TraceEventType.Critical:
color = new XAttribute("bgcolor", "red");
break;
default:
color = new XAttribute("bgcolor", "pink");
break;
}
XElement row = new XElement("tr");
row.Add(
new XElement("td", " ", color),
new XElement("td", string.Format("{0} {1}", logEntry.TimeStamp.ToShortDateString(), logEntry.TimeStamp.ToShortTimeString())),
new XElement("td", new XElement("pre", logEntry.Message.Replace("\n", ""))),
new XElement("td", logEntry.Title),
new XElement("td", logEntry.Severity)
//new XElement("td", logEntry.HttpRequestUrl ?? "" + " "),
//new XElement("td", logEntry.HttpReferingUrl ?? "" + " ")
);
table.Add(row);
}
LogHolder.Controls.Add(new LiteralControl(table.ToString()));
}
示例2: BuildLogTable
private void BuildLogTable(LogEntry[] entries)
{
XElement table = new XElement("table");
XElement tableHeader = new XElement("tr");
tableHeader.Add(
new XElement("th", " "),
new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.DateLabel")),
new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.MessageLabel")),
new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.TitleLabel")),
new XElement("th", StringResourceSystemFacade.GetString("Composite.Management","ServerLog.LogEntry.EventTypeLabel"))
);
table.Add(tableHeader);
foreach (LogEntry logEntry in entries.Reverse())
{
TraceEventType eventType;
try
{
eventType = (TraceEventType)Enum.Parse(typeof(TraceEventType), logEntry.Severity);
}
catch (Exception)
{
eventType = TraceEventType.Information;
}
var colors = new []
{
new Tuple<TraceEventType, string>(TraceEventType.Information, "lime"),
new Tuple<TraceEventType, string>(TraceEventType.Verbose, "white"),
new Tuple<TraceEventType, string>(TraceEventType.Warning, "yellow"),
new Tuple<TraceEventType, string>(TraceEventType.Error, "orange"),
new Tuple<TraceEventType, string>(TraceEventType.Critical, "red")
};
string colorName = colors.Where(c => c.Item1 == eventType).Select(c => c.Item2).FirstOrDefault() ?? "orange";
XAttribute color = new XAttribute("bgcolor", colorName);
XElement row = new XElement("tr");
row.Add(
new XElement("td", color, " "),
new XElement("td", logEntry.TimeStamp.ToString(View_DateTimeFormat)),
new XElement("td", new XElement("pre", EncodeXml10InvalidCharacters(logEntry.Message.Replace("\n", "")))),
new XElement("td", EncodeXml10InvalidCharacters(logEntry.Title)),
new XElement("td", logEntry.Severity)
);
table.Add(row);
}
LogHolder.Controls.Add(new LiteralControl(table.ToString()));
}