本文整理汇总了C#中System.Xml.XmlWriter.WriteRawAsync方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.WriteRawAsync方法的具体用法?C# XmlWriter.WriteRawAsync怎么用?C# XmlWriter.WriteRawAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.WriteRawAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EncodeAsync
internal static async Task EncodeAsync(byte[] buffer, int index, int count, XmlWriter writer)
{
if (buffer == null)
{
throw new ArgumentNullException("buffer");
}
if (index < 0)
{
throw new ArgumentOutOfRangeException("index");
}
if (count < 0)
{
throw new ArgumentOutOfRangeException("count");
}
if (count > buffer.Length - index)
{
throw new ArgumentOutOfRangeException("count");
}
char[] chars = new char[(count * 2) < CharsChunkSize ? (count * 2) : CharsChunkSize];
int endIndex = index + count;
while (index < endIndex)
{
int cnt = (count < CharsChunkSize / 2) ? count : CharsChunkSize / 2;
int charCount = Encode(buffer, index, cnt, chars);
await writer.WriteRawAsync(chars, 0, charCount).ConfigureAwait(false);
index += cnt;
count -= cnt;
}
}
示例2: ReplayAsync
internal async Task ReplayAsync(XmlWriter writer) {
if (singleStringValue != null) {
await writer.WriteStringAsync(singleStringValue).ConfigureAwait(false);
return;
}
BufferChunk bufChunk;
for (int i = firstItem; i <= lastItem; i++) {
Item item = items[i];
switch (item.type) {
case ItemType.EntityRef:
await writer.WriteEntityRefAsync((string)item.data).ConfigureAwait(false);
break;
case ItemType.CharEntity:
await writer.WriteCharEntityAsync((char)item.data).ConfigureAwait(false);
break;
case ItemType.SurrogateCharEntity:
char[] chars = (char[])item.data;
await writer.WriteSurrogateCharEntityAsync(chars[0], chars[1]).ConfigureAwait(false);
break;
case ItemType.Whitespace:
await writer.WriteWhitespaceAsync((string)item.data).ConfigureAwait(false);
break;
case ItemType.String:
await writer.WriteStringAsync((string)item.data).ConfigureAwait(false);
break;
case ItemType.StringChars:
bufChunk = (BufferChunk)item.data;
await writer.WriteCharsAsync(bufChunk.buffer, bufChunk.index, bufChunk.count).ConfigureAwait(false);
break;
case ItemType.Raw:
await writer.WriteRawAsync((string)item.data).ConfigureAwait(false);
break;
case ItemType.RawChars:
bufChunk = (BufferChunk)item.data;
await writer.WriteCharsAsync(bufChunk.buffer, bufChunk.index, bufChunk.count).ConfigureAwait(false);
break;
case ItemType.ValueString:
await writer.WriteStringAsync((string)item.data).ConfigureAwait(false);
break;
default:
Debug.Assert(false, "Unexpected ItemType value.");
break;
}
}
}
示例3: RenderPageNavigatorsAsync
private async Task RenderPageNavigatorsAsync(XmlWriter writer)
{
await writer.WriteStartElementAsync("p");
{
var nextPageIndex = pageIndex + 1;
var moreErrors = nextPageIndex*pageSize < totalCount;
if (moreErrors)
{
await writer.WriteStartElementAsync("a");
await writer.WriteAttributeStringAsync("href", $"{BasePageName}?page={nextPageIndex + 1}&size={pageSize}");
await writer.WriteAttributeStringAsync("rel", "next");
{
await writer.WriteStringAsync("Next errors");
}
await writer.WriteEndElementAsync();
}
// If not on the first page then render a link to the firs page.
if (pageIndex > 0 && totalCount > 0)
{
if (moreErrors)
await writer.WriteRawAsync("; ");
await writer.WriteStartElementAsync("a");
await writer.WriteAttributeStringAsync("href", $"{BasePageName}?page=1&size={pageSize}");
await writer.WriteAttributeStringAsync("rel", "start");
{
await writer.WriteStringAsync("Back to first page");
}
await writer.WriteEndElementAsync();
}
}
await writer.WriteEndElementAsync();
}
示例4: RenderErrorsAsync
private async Task RenderErrorsAsync(XmlWriter writer)
{
//
// Create a table to display error information in each row.
//
await writer.WriteStartElementAsync("table");
await writer.WriteAttributeStringAsync("id", "ErrorLog");
await writer.WriteAttributeStringAsync("style", "border-spacing: 0;");
{
//
// Create the table row for headings.
//
await writer.WriteStartElementAsync("tr");
{
await RenderCellAsync(writer, "th", "Host", "host-col");
await RenderCellAsync(writer, "th", "Code", "code-col");
await RenderCellAsync(writer, "th", "Type", "type-col");
await RenderCellAsync(writer, "th", "Error", "error-col");
await RenderCellAsync(writer, "th", "User", "user-col");
await RenderCellAsync(writer, "th", "Date", "date-col");
await RenderCellAsync(writer, "th", "Time", "time-col");
}
await writer.WriteEndElementAsync();
//
// Generate a table body row for each error.
//
for (int index = 0; index < errorLogEntries.Count; index++)
{
var errorLogEntry = errorLogEntries[index];
await writer.WriteStartElementAsync("tr");
await writer.WriteAttributeStringAsync("class", index % 2 == 0 ? "even-row" : "odd-row");
{
// Format host and status code cells.
var error = errorLogEntry.Error;
await RenderCellAsync(writer, "td", error.HostName, "host-col");
await RenderCellAsync(writer, "td", error.StatusCode.ToString(), "code-col", HttpCodeParser.GetstatusDescription(error.StatusCode));
await RenderCellAsync(writer, "td", ErrorShortName(error.TypeName), "host-col", error.TypeName);
//
// Format the message cell, which contains the message
// text and a details link pointing to the page where
// all error details can be viewed.
//
await writer.WriteStartElementAsync("td");
await writer.WriteAttributeStringAsync("class", "error-col");
{
await writer.WriteStartElementAsync("label");
{
await writer.WriteStringAsync(error.Message);
}
await writer.WriteEndElementAsync();
await writer.WriteStartElementAsync("a");
await writer.WriteAttributeStringAsync("href", $"{BasePageName}/detail?id={errorLogEntry.Id}");
{
await writer.WriteRawAsync("Details…");
}
await writer.WriteEndElementAsync();
}
await writer.WriteEndElementAsync();
// Format the user, date and time cells.
await RenderCellAsync(writer, "td", error.User, "user-col");
await RenderCellAsync(writer, "td", error.Time.DateTime.ToShortDateString(), "date-col", error.Time.DateTime.ToLongDateString());
await RenderCellAsync(writer, "td", error.Time.DateTime.ToShortTimeString(), "time-col", error.Time.DateTime.ToLongTimeString());
}
await writer.WriteEndElementAsync();
}
}
await writer.WriteEndElementAsync();
}
示例5: RenderCellAsync
private static async Task RenderCellAsync(XmlWriter writer, string cellType, string contents, string cssClassName, string tooltip = "")
{
await writer.WriteStartElementAsync(cellType);
await writer.WriteAttributeStringAsync("class", cssClassName);
if (string.IsNullOrEmpty(contents?.Trim()))
{
await writer.WriteRawAsync(" ");
}
else
{
if (string.IsNullOrEmpty(tooltip?.Trim()))
{
await writer.WriteStringAsync(contents);
}
else
{
await writer.WriteStartElementAsync("label");
await writer.WriteAttributeStringAsync("title", tooltip);
await writer.WriteStringAsync(contents);
await writer.WriteEndElementAsync();
}
}
await writer.WriteEndElementAsync();
}