本文整理汇总了C#中CsvWriter.Field方法的典型用法代码示例。如果您正苦于以下问题:C# CsvWriter.Field方法的具体用法?C# CsvWriter.Field怎么用?C# CsvWriter.Field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsvWriter
的用法示例。
在下文中一共展示了CsvWriter.Field方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Entries
public override void Entries(IList entries, int index, int count, int total)
{
Debug.Assert(entries != null);
Debug.Assert(index >= 0);
Debug.Assert(index + count <= entries.Count);
if (count == 0)
return;
//
// Setup to emit CSV records.
//
StringWriter writer = new StringWriter();
writer.NewLine = "\r\n";
CsvWriter csv = new CsvWriter(writer);
CultureInfo culture = CultureInfo.InvariantCulture;
DateTime epoch = new DateTime(1970, 1, 1);
//
// For each error, emit a CSV record.
//
for (int i = index; i < count; i++)
{
ErrorLogEntry entry = (ErrorLogEntry) entries[i];
Error error = entry.Error;
DateTime time = error.Time.ToUniversalTime();
string query = "?id=" + HttpUtility.UrlEncode(entry.Id);
Uri requestUrl = ErrorLogPageFactory.GetRequestUrl(Context);
csv.Field(error.ApplicationName)
.Field(error.HostName)
.Field(time.ToString("yyyy-MM-dd HH:mm:ss", culture))
.Field(time.Subtract(epoch).TotalSeconds.ToString("0.0000", culture))
.Field(error.Type)
.Field(error.Source)
.Field(error.User)
.Field(error.StatusCode.ToString(culture))
.Field(error.Message)
.Field(new Uri(requestUrl, "detail" + query).ToString())
.Field(new Uri(requestUrl, "xml" + query).ToString())
.Field(new Uri(requestUrl, "json" + query).ToString())
.Record();
}
Context.Response.Output.Write(writer.ToString());
}