本文整理匯總了C#中System.Xml.XmlTextReader.HasLineInfo方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.HasLineInfo方法的具體用法?C# XmlTextReader.HasLineInfo怎麽用?C# XmlTextReader.HasLineInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.HasLineInfo方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AddReference
private LocalizedString AddReference(LocalizedString localizedString, XmlTextReader reader, string xamlPath)
{
if (reader.HasLineInfo ()) {
localizedString.AddReference (RelativeDocumentUrl (xamlPath), reader.LineNumber);
}
return localizedString;
}
示例2: Parse
private IEnumerable<LocalizedString> Parse(string xamlPath)
{
using (var reader = new XmlTextReader (xamlPath)) {
while (reader.Read ()) {
if (reader.NodeType != XmlNodeType.Element || !reader.HasAttributes) {
continue;
}
var in_app_bar = false;
if (reader.NamespaceURI.Contains ("clr-namespace:Microsoft.Phone.Shell")) {
var name = reader.Name.Substring (reader.Prefix.Length + 1);
in_app_bar = name == "ApplicationBarIconButton" || name == "ApplicationBarMenuItem";
}
var localized_string = new LocalizedString ();
while (reader.MoveToNextAttribute ()) {
if (!in_app_bar && !reader.NamespaceURI.Contains ("clr-namespace:Vernacular.Xaml")) {
continue;
}
var name = String.IsNullOrEmpty (reader.Prefix)
? reader.Name
: reader.Name.Substring (reader.Prefix.Length + 1);
switch (name) {
case "Text": // only valid when in_app_bar is true
case "Catalog.Message":
localized_string.UntranslatedSingularValue = reader.Value;
if (reader.HasLineInfo ()) {
localized_string.AddReference (RelativeDocumentUrl (xamlPath), reader.LineNumber);
}
break;
case "Catalog.PluralMessage":
localized_string.UntranslatedPluralValue = reader.Value;
break;
case "Catalog.Comment":
localized_string.DeveloperComments = reader.Value;
break;
}
}
if (localized_string.IsDefined) {
yield return localized_string;
}
reader.MoveToElement ();
}
}
}