本文整理汇总了C#中System.Xml.XmlWriter.WriteEndElementAsync方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.WriteEndElementAsync方法的具体用法?C# XmlWriter.WriteEndElementAsync怎么用?C# XmlWriter.WriteEndElementAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.WriteEndElementAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderHeadAsync
private async Task RenderHeadAsync(XmlWriter writer)
{
await writer.WriteStartElementAsync("meta");
await writer.WriteAttributeStringAsync("http-equiv", "X-UA-Compatible");
await writer.WriteAttributeStringAsync("content", "IE=EmulateIE7");
await writer.WriteEndElementAsync();
await writer.WriteElementStringAsync("title", PageTitle);
await writer.WriteStartElementAsync("link");
await writer.WriteAttributeStringAsync("rel", "stylesheet");
await writer.WriteAttributeStringAsync("type", "text/css");
await writer.WriteAttributeStringAsync("href", BasePageName + "/stylesheet");
await writer.WriteEndElementAsync();
}
示例2: RenderContentsAsync
protected override async Task RenderContentsAsync(XmlWriter writer)
{
await RenderTitleAsync(writer);
await
SpeedBarComponent.RenderAsync(writer, SpeedBarComponent.GetRssFeed(BasePageName),
SpeedBarComponent.GetRssDigestFeed(BasePageName), SpeedBarComponent.GetDownloadLog(BasePageName));
if (errorLogEntries.Count < 1)
{
await RenderNoErrorsAsync(writer);
}
else
{
// Write error number range displayed on this page and the
// total available in the log, followed by stock
// page sizes.
await writer.WriteStartElementAsync("p");
await RenderStatsAsync(writer);
await RenderStockPageSizesAsync(writer);
await writer.WriteEndElementAsync(); // </p>
// Write out the main table to display the errors.
await RenderErrorsAsync(writer);
// Write out page navigation links.
await RenderPageNavigatorsAsync(writer);
}
}
示例3: RenderDocumentStartAsync
private async Task RenderDocumentStartAsync(XmlWriter writer)
{
await writer.WriteDocTypeAsync("html"); // doctype
await writer.WriteStartElementAsync(null, "html", "http://www.w3.org/1999/xhtml"); // html start
await writer.WriteStartElementAsync("head"); // head start
await RenderHeadAsync(writer);
await writer.WriteEndElementAsync(); // head end
await writer.WriteStartElementAsync("body"); // body start
}
示例4: RenderAsync
public static async Task RenderAsync(XmlWriter writer, params SpeedBarItem[] items)
{
if (items == null || items.Length == 0)
return;
await writer.WriteStartElementAsync("ul");
await writer.WriteAttributeStringAsync("id", "SpeedList");
foreach (var item in items)
{
await writer.WriteStartElementAsync("li");
await writer.WriteStartElementAsync("a");
await writer.WriteAttributeStringAsync("href", item.Url);
await writer.WriteAttributeStringAsync("title", item.Title);
await writer.WriteStringAsync(item.Label);
await writer.WriteEndElementAsync();
await writer.WriteEndElementAsync();
}
await writer.WriteEndElementAsync();
}
示例5: 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();
}
示例6: 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();
}
示例7: RenderTitleAsync
private async Task RenderTitleAsync(XmlWriter writer)
{
await writer.WriteStartElementAsync("h1");
await writer.WriteAttributeStringAsync("id", "PageTitle");
await writer.WriteStringAsync("Error Log for ");
await writer.WriteStartElementAsync("span");
await writer.WriteAttributeStringAsync("id", "ApplicationName");
await writer.WriteAttributeStringAsync("title", ApplicationName);
await writer.WriteStringAsync(ApplicationName);
var machineName = EnvironmentUtilities.GetMachineNameOrDefault();
if (!string.IsNullOrEmpty(machineName?.Trim()))
{
await writer.WriteStringAsync(" on ");
await writer.WriteStringAsync(machineName);
}
await writer.WriteEndElementAsync(); // </span>
await writer.WriteEndElementAsync(); // </h1>
}
示例8: RenderNoErrorsAsync
private async Task RenderNoErrorsAsync(XmlWriter writer)
{
await writer.WriteStartElementAsync("p");
await writer.WriteStringAsync("No errors found. ");
//
// It is possible that there are no error at the requested
// page in the log (especially if it is not the first page).
// However, if there are error in the log
//
if (pageIndex > 0 && totalCount > 0)
{
var href = $"{BasePageName}?page=1&size={pageSize}";
await writer.WriteStartElementAsync("a");
await writer.WriteAttributeStringAsync("href", href);
await writer.WriteAttributeStringAsync("rel", "start");
await writer.WriteStringAsync("Go to first page");
await writer.WriteEndElementAsync();
await writer.WriteStringAsync(". ");
}
await writer.WriteEndElementAsync();
}
示例9: RenderStockPageSizesAsync
private async Task RenderStockPageSizesAsync(XmlWriter writer)
{
//
// Write out a set of stock page size choices. Note that
// selecting a stock page size re-starts the log
// display from the first page to get the right paging.
//
await writer.WriteStringAsync("Start with ");
var stockSizes = new[] { 10, 15, 20, 25, 30, 50, 100 };
for (var stockSizeIndex = 0; stockSizeIndex < stockSizes.Length; stockSizeIndex++)
{
var stockSize = stockSizes[stockSizeIndex];
if (stockSizeIndex > 0)
await writer.WriteStringAsync(stockSizeIndex + 1 < stockSizes.Length ? ", " : " or ");
var href = $"{BasePageName}?page=1&size={stockSize}";
await writer.WriteStartElementAsync("a");
await writer.WriteAttributeStringAsync("href", href);
await writer.WriteAttributeStringAsync("rel", "start");
await writer.WriteStringAsync(stockSize.ToString());
await writer.WriteEndElementAsync();
}
await writer.WriteStringAsync(" errors per page.");
}
示例10: 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();
}
示例11: RenderErrorAsync
private async Task RenderErrorAsync(XmlWriter writer)
{
var error = errorLogEntry.Error;
await writer.WriteStartElementAsync("h1");
await writer.WriteAttributeStringAsync("id", "PageTitle");
{
await writer.WriteStringAsync(error.Message);
}
await writer.WriteEndElementAsync();
await SpeedBarComponent.RenderAsync(writer, SpeedBarComponent.GetHome(BasePageName));
await writer.WriteStartElementAsync("p");
await writer.WriteAttributeStringAsync("id", "ErrorTitle");
{
await writer.WriteStartElementAsync("span");
await writer.WriteAttributeStringAsync("id", "ErrorType");
{
await writer.WriteStringAsync(error.TypeName);
}
await writer.WriteEndElementAsync();
await writer.WriteStartElementAsync("span");
await writer.WriteAttributeStringAsync("id", "ErrorTypeMessageSeparator");
{
await writer.WriteStringAsync(": ");
}
await writer.WriteEndElementAsync();
await writer.WriteStartElementAsync("span");
await writer.WriteAttributeStringAsync("id", "ErrorMessage");
{
await writer.WriteStringAsync(error.Message);
}
await writer.WriteEndElementAsync();
}
await writer.WriteEndElementAsync();
await writer.WriteStartElementAsync("pre");
await writer.WriteAttributeStringAsync("id", "ErrorDetail");
{
await writer.WriteStringAsync(error.Detail);
}
await writer.WriteEndElementAsync();
await writer.WriteStartElementAsync("p");
await writer.WriteAttributeStringAsync("id", "ErrorLogTime");
{
await writer.WriteStringAsync($"Logged on {error.Time}.");
}
await writer.WriteEndElementAsync();
await writer.WriteStartElementAsync("p");
{
await writer.WriteStringAsync("See also:");
}
await writer.WriteEndElementAsync();
await writer.WriteStartElementAsync("ul");
{
await writer.WriteStartElementAsync("li");
{
await writer.WriteStringAsync("Raw/Source data in ");
await writer.WriteStartElementAsync("a");
await writer.WriteAttributeStringAsync("href", "json" + requestQuery);
await writer.WriteAttributeStringAsync("rel", "alternate");
await writer.WriteAttributeStringAsync("type", "application/json");
{
await writer.WriteStringAsync("JSON");
}
await writer.WriteEndElementAsync();
}
await writer.WriteEndElementAsync();
}
await writer.WriteEndElementAsync();
await RenderDictionaryAsync(writer, error.ServerEnvironment, "ServerVariables", "Server Environment");
await RenderDictionaryAsync(writer, error.Headers.ToDictionary(pair => pair.Key, pair => string.Join(", ", pair.Value)), "ServerVariables", "Headers");
await RenderDictionaryAsync(writer, error.Query.ToDictionary(pair => pair.Key, pair => string.Join(", ", pair.Value)), "ServerVariables", "Query");
await RenderDictionaryAsync(writer, error.Cookies, "ServerVariables", "Cookies");
}
示例12: RenderNoErrorAsync
private static async Task RenderNoErrorAsync(XmlWriter writer)
{
await writer.WriteStartElementAsync("p");
await writer.WriteStringAsync("Error not found in log.");
await writer.WriteEndElementAsync();
}
示例13: RenderDictionaryAsync
private static async Task RenderDictionaryAsync(XmlWriter writer, Dictionary<string, string> dictionary, string id, string title)
{
if (!dictionary.Any())
return;
await writer.WriteStartElementAsync("div");
await writer.WriteAttributeStringAsync("id", id);
{
await writer.WriteStartElementAsync("p");
await writer.WriteAttributeStringAsync("class", "table-caption");
{
await writer.WriteStringAsync(title);
}
await writer.WriteEndElementAsync();
await writer.WriteStartElementAsync("div");
await writer.WriteAttributeStringAsync("class", "scroll-view");
{
await writer.WriteStartElementAsync("table");
{
await writer.WriteStartElementAsync("tr");
{
await writer.WriteStartElementAsync("th");
await writer.WriteAttributeStringAsync("class", "name-col");
{
await writer.WriteStringAsync("Name");
}
await writer.WriteEndElementAsync();
await writer.WriteStartElementAsync("th");
await writer.WriteAttributeStringAsync("class", "value-col");
{
await writer.WriteStringAsync("Value");
}
await writer.WriteEndElementAsync();
}
await writer.WriteEndElementAsync();
var count = 0;
foreach (var line in dictionary)
{
await writer.WriteStartElementAsync("tr");
await writer.WriteAttributeStringAsync("class", count%2 == 0 ? "even-row" : "odd-row");
{
await writer.WriteStartElementAsync("td");
await writer.WriteAttributeStringAsync("class", "key-col");
{
await writer.WriteStringAsync(line.Key);
}
await writer.WriteEndElementAsync();
await writer.WriteStartElementAsync("td");
await writer.WriteAttributeStringAsync("class", "value-col");
{
await writer.WriteStringAsync(line.Value);
}
await writer.WriteEndElementAsync();
}
await writer.WriteEndElementAsync();
}
}
await writer.WriteEndElementAsync();
}
await writer.WriteEndElementAsync();
}
await writer.WriteEndElementAsync();
await writer.WriteElementStringAsync("br", string.Empty);
}
示例14: ToXml
private static async Task ToXml(object obj, XmlWriter writer, SerializerOptions options = null)
{
var type = obj.GetType();
var typeInfo = type.GetTypeInfo();
if (typeInfo.IsPrimitive || type == typeof(string) || type == typeof(decimal))
{
await writer.WriteStringAsync(Convert.ToString(obj, CultureInfo.InvariantCulture));
}
else if (typeInfo.IsEnum)
{
await writer.WriteStringAsync(Enum.GetName(type, obj));
}
else if (type == typeof(DateTime))
{
var format = DateFormatForOptions(options);
await writer.WriteStringAsync(((DateTime)obj).ToString(format));
}
else if (typeInfo.ImplementedInterfaces.Contains(typeof(IEnumerable)))
{
foreach (var val in (IEnumerable) obj)
{
await writer.WriteStartElementAsync(null, NameForType(val.GetType()), null);
await ToXml(val, writer);
await writer.WriteEndElementAsync();
}
}
else
{
foreach(var property in type.GetRuntimeProperties())
{
SerializerOptions opt = null;
var ignoreAttr = property.GetCustomAttribute<XmlIgnoreAttribute>();
var isStatic = property.GetMethod.IsStatic;
if (ignoreAttr != null || isStatic)
{
continue;
}
var attr = property.GetCustomAttribute<XmlElementAttribute>();
if (attr != null)
{
opt = new SerializerOptions { DataType = attr.DataType, };
}
var value = property.GetMethod.Invoke(obj, new object[0]);
await writer.WriteStartElementAsync(null, property.Name, null);
if (value != null)
{
await ToXmlNode(value, writer, opt);
}
await writer.WriteEndElementAsync();
}
}
}
示例15: RenderDocumentEndAsync
private async Task RenderDocumentEndAsync(XmlWriter writer)
{
//
// Write the powered-by signature, that includes version information.
//
await writer.WriteStartElementAsync("p"); // <p>
await writer.WriteAttributeStringAsync("id", "Footer");
//PoweredBy poweredBy = new PoweredBy();
//poweredBy.RenderControl(writer);
//
// Write out server date, time and time zone details.
//
var now = DateTime.Now;
await writer.WriteStringAsync("Server date is ");
await writer.WriteStringAsync(now.ToString("D", CultureInfo.InvariantCulture));
await writer.WriteStringAsync(". Server time is ");
await writer.WriteStringAsync(now.ToString("T", CultureInfo.InvariantCulture));
await writer.WriteStringAsync(". All dates and times displayed are in the ");
await writer.WriteStringAsync(TimeZone.CurrentTimeZone.IsDaylightSavingTime(now) ?
TimeZone.CurrentTimeZone.DaylightName : TimeZone.CurrentTimeZone.StandardName);
await writer.WriteStringAsync(" zone. ");
//
// Write out the source of the log.
//
await writer.WriteStringAsync("This log is provided by the ");
await writer.WriteStringAsync(ErrorLog.Name);
await writer.WriteStringAsync(".");
await writer.WriteEndElementAsync();// </p>
await writer.WriteEndElementAsync(); // </body>
await writer.WriteEndElementAsync(); // </html>
}