本文整理汇总了C#中System.Xml.XmlReader.ReadElementContentAsInt方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadElementContentAsInt方法的具体用法?C# XmlReader.ReadElementContentAsInt怎么用?C# XmlReader.ReadElementContentAsInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadElementContentAsInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: readItems
private void readItems(XmlReader reader) {
reader.ReadToFollowing ("ItemDatabase");
bool continueReading = reader.ReadToDescendant ("Item");
while (continueReading) {
//Read all information from the .xml-file
reader.ReadToDescendant ("Id");
int id = reader.ReadElementContentAsInt ();
reader.ReadToNextSibling ("Name");
string name = reader.ReadElementContentAsString ();
reader.ReadToNextSibling ("Description");
string desc = reader.ReadElementContentAsString ();
reader.ReadToNextSibling ("Value");
int value = reader.ReadElementContentAsInt ();
reader.ReadToNextSibling ("Type");
string type = reader.ReadElementContentAsString ();
ItemType t = type.StringToType ();
//And add the item to the database
Item i = new Item (name, desc, value, t, id);
//check for attributes and add them to the item
checkForAttributes(reader, i);
//Add the item to the databse and read end element
items.Add(i);
reader.ReadEndElement ();
//Check if there is another item to read
continueReading = reader.ReadToNextSibling ("Item");
}
}
示例2: while
void IFlickrParsable.Load(XmlReader reader)
{
reader.Read();
while (reader.LocalName != "photos")
{
switch (reader.LocalName)
{
case "firstdatetaken":
this.FirstTakenDate = UtilityMethods.ParseDateWithGranularity(reader.ReadElementContentAsString());
continue;
case "firstdate":
this.FirstDate = UtilityMethods.UnixTimestampToDate(reader.ReadElementContentAsString());
continue;
case "count":
this.PhotoCount = reader.ReadElementContentAsInt();
continue;
case "views":
this.Views = reader.ReadElementContentAsInt();
continue;
default:
reader.Skip();
continue;
}
}
reader.Read();
}
示例3: ReadXml
public void ReadXml(XmlReader reader)
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.EndElement)
{
break;
}
if (reader.NodeType == XmlNodeType.Whitespace)
{
continue;
}
switch (reader.Name)
{
case "portalID":
PortalID = reader.ReadElementContentAsInt();
break;
case "portalAliasID":
PortalAliasID = reader.ReadElementContentAsInt();
break;
case "HTTPAlias":
HTTPAlias = reader.ReadElementContentAsString();
break;
}
}
}
示例4: Read
internal static void Read(XmlReader reader, TransactionSearchResult result)
{
if (reader == null)
throw new ArgumentNullException("reader");
if (result == null)
throw new ArgumentNullException("result");
if (reader.IsEmptyElement)
{
SerializationHelper.SkipNode(reader);
return;
}
reader.ReadStartElement(TransactionSearchResultSerializer.TransactionSearchResult);
reader.MoveToContent();
while (!reader.EOF)
{
if (SerializationHelper.IsEndElement(reader, TransactionSearchResultSerializer.TransactionSearchResult))
{
SerializationHelper.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case TransactionSearchResultSerializer.Date:
result.Date = reader.ReadElementContentAsDateTime();
break;
case TransactionSearchResultSerializer.CurrentPage:
result.CurrentPage = reader.ReadElementContentAsInt();
break;
case TransactionSearchResultSerializer.TotalPages:
result.TotalPages = reader.ReadElementContentAsInt();
break;
case TransactionSummaryListSerializer.Transactions:
TransactionSummaryListSerializer.Read(reader, result.Items);
break;
default:
SerializationHelper.SkipElement(reader);
break;
}
}
else
{
SerializationHelper.SkipNode(reader);
}
}
}
示例5: ReadXml
public void ReadXml(XmlReader reader)
{
if (reader.LocalName != "icon" && !reader.ReadToDescendant("icon"))
throw new InvalidDataException();
XmlHelper.ParseXml(reader, new XmlParseSet
{
{"url", () => this.RelativeUrl = reader.ReadString()},
{"mimetype", () => this.MimeType = reader.ReadString()},
{"width", () => this.Width = reader.ReadElementContentAsInt()},
{"height", () => this.Height = reader.ReadElementContentAsInt()},
{"depth", () => this.Depth = reader.ReadElementContentAsInt()}
});
}
示例6: Read
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="result"></param>
internal static void Read(XmlReader reader, PreApprovalSearchResult result)
{
if (reader.IsEmptyElement)
{
XMLParserUtils.SkipNode(reader);
return;
}
reader.ReadStartElement(PreApprovalSearchResultSerializer.PreApprovalSearchResult);
reader.MoveToContent();
while (!reader.EOF)
{
if (XMLParserUtils.IsEndElement(reader, PreApprovalSearchResultSerializer.PreApprovalSearchResult))
{
XMLParserUtils.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case PreApprovalSearchResultSerializer.Date:
result.Date = reader.ReadElementContentAsDateTime();
break;
case PreApprovalSearchResultSerializer.CurrentPage:
result.CurrentPage = reader.ReadElementContentAsInt();
break;
case PreApprovalSearchResultSerializer.TotalPages:
result.TotalPages = reader.ReadElementContentAsInt();
break;
case PreApprovalSummaryListSerializer.PreApprovals:
PreApprovalSummaryListSerializer.Read(reader, result.PreApprovals);
break;
default:
XMLParserUtils.SkipElement(reader);
break;
}
}
else
{
XMLParserUtils.SkipNode(reader);
}
}
}
示例7: ParseXml
internal static MarketplaceAppImageNode ParseXml(XmlReader reader)
{
var node = new MarketplaceAppImageNode();
reader.ReadStartElement();
while (reader.NodeType != XmlNodeType.EndElement)
{
switch (reader.LocalName)
{
case "id":
node.Id = reader.ReadElementContentAsUrn();
break;
case "orientation":
node.Orientation = reader.ReadElementContentAsInt();
break;
default:
reader.Skip();
break;
}
}
reader.ReadEndElement();
return node;
}
示例8: ParseXml
internal static WindowsPhoneStoreServiceAppImageNode ParseXml(XmlReader reader)
{
var node = new WindowsPhoneStoreServiceAppImageNode();
if (reader.IsEmptyElement)
{
reader.Skip();
}
else
{
reader.ReadStartElement();
while (reader.NodeType != XmlNodeType.EndElement)
{
switch (reader.LocalName)
{
case "id":
node.Id = reader.ReadElementContentAsUrn();
break;
case "orientation":
node.Orientation = reader.ReadElementContentAsInt();
break;
default:
reader.Skip();
break;
}
}
reader.ReadEndElement();
}
return node;
}
示例9: FromXml
public bool FromXml(XmlReader reader)
{
if (reader == null || reader.Name != "Lib")
{
return false;
}
if (reader.Name == "Order" || reader.ReadToDescendant("Order"))
{
Order = reader.ReadElementContentAsInt();
}
if (reader.Name == "Id" || reader.ReadToNextSibling("Id"))
{
Id = reader.ReadElementContentAsString();
}
if (reader.Name == "Name" || reader.ReadToNextSibling("Name"))
{
Name = reader.ReadElementContentAsString();
}
if (reader.Name == "Text" || reader.ReadToNextSibling("Text"))
{
Text = reader.ReadElementContentAsString();
}
if (reader.Name == "Memo" || reader.ReadToNextSibling("Memo"))
{
Memo = reader.ReadElementContentAsString();
}
return true;
}
示例10: while
void IFlickrParsable.Load(XmlReader reader)
{
while (reader.NodeType != XmlNodeType.EndElement)
{
switch (reader.LocalName)
{
case "count":
this.Count = reader.ReadElementContentAsInt();
continue;
case "prevphoto":
this.PreviousPhoto = new ContextPhoto();
this.PreviousPhoto.Load(reader);
if (this.PreviousPhoto.PhotoId == "0")
{
this.PreviousPhoto = (ContextPhoto) null;
continue;
}
else
continue;
case "nextphoto":
this.NextPhoto = new ContextPhoto();
this.NextPhoto.Load(reader);
if (this.NextPhoto.PhotoId == "0")
{
this.NextPhoto = (ContextPhoto) null;
continue;
}
else
continue;
default:
continue;
}
}
}
示例11: FromXml
public bool FromXml(XmlReader reader)
{
if (reader == null || reader.Name != "Ren" || !reader.IsStartElement())
{
return false;
}
if (reader.Name == "Order" || reader.ReadToDescendant("Order"))
{
Order = reader.ReadElementContentAsInt();
}
if (reader.Name == "Id" || reader.ReadToNextSibling("Id"))
{
Id = reader.ReadElementContentAsString();
}
if (reader.Name == "Name" || reader.ReadToNextSibling("Name"))
{
Name = reader.ReadElementContentAsString();
}
if (reader.Name == "Command" || reader.ReadToNextSibling("Command"))
{
Command = reader.ReadElementContentAsString();
}
if (reader.Name == "Remark" || reader.ReadToNextSibling("Remark"))
{
Remark = reader.ReadElementContentAsString();
}
if (reader.Name == "Ren" && reader.NodeType == XmlNodeType.EndElement)
{
reader.ReadEndElement();
}
return true;
}
示例12: ReadAreaType
public static AreaType ReadAreaType(XmlReader reader, Counter<string> badTags)
{
string type = null;
int level = 0;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "type")
{
type = reader.ReadElementContentAsString();
}
else if (reader.NodeType == XmlNodeType.Element && reader.Name == "level")
{
level = reader.ReadElementContentAsInt();
}
else if (reader.NodeType == XmlNodeType.Element)
{
badTags.Increment(reader.Name);
}
else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "area")
{
break;
}
}
if (level == 0 || type == null)
throw new Exception("Area type or level not specified.");
return new AreaType(level, type);
}
示例13: ParseXml
internal static WindowsStoreServiceAppCategoryNode ParseXml(XmlReader reader)
{
var node = new WindowsStoreServiceAppCategoryNode();
reader.ReadStartElement();
while (reader.NodeType != XmlNodeType.EndElement)
{
switch (reader.Name)
{
case "I":
node.Id = reader.ReadElementContentAsInt();
break;
case "N":
node.Name = reader.ReadElementContentAsString();
break;
default:
reader.Skip();
break;
}
}
reader.ReadEndElement();
return node;
}
示例14: Read
internal static void Read(XmlReader reader, PaymentMethod paymentMethod)
{
if (reader == null)
throw new ArgumentNullException("reader");
if (paymentMethod == null)
throw new ArgumentNullException("paymentMethod");
if (reader.IsEmptyElement)
{
SerializationHelper.SkipNode(reader);
return;
}
reader.ReadStartElement(PaymentMethodSerializer.PaymentMethod);
reader.MoveToContent();
while (!reader.EOF)
{
if (SerializationHelper.IsEndElement(reader, PaymentMethodSerializer.PaymentMethod))
{
SerializationHelper.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case PaymentMethodSerializer.PaymentMethodType:
paymentMethod.PaymentMethodType = reader.ReadElementContentAsInt();
break;
case PaymentMethodSerializer.PaymentMethodCode:
paymentMethod.PaymentMethodCode = reader.ReadElementContentAsInt();
break;
default:
SerializationHelper.SkipElement(reader);
break;
}
}
else
{
SerializationHelper.SkipNode(reader);
}
}
}
示例15: Read
internal static void Read(XmlReader reader, Item item)
{
if (reader == null)
throw new ArgumentNullException("reader");
if (item == null)
throw new ArgumentNullException("item");
if (reader.IsEmptyElement)
{
SerializationHelper.SkipNode(reader);
return;
}
reader.ReadStartElement(ItemSerializer.Item);
reader.MoveToContent();
while (!reader.EOF)
{
if (SerializationHelper.IsEndElement(reader, ItemSerializer.Item))
{
SerializationHelper.SkipNode(reader);
break;
}
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case ItemSerializer.Id:
item.Id = reader.ReadElementContentAsString();
break;
case ItemSerializer.Description:
item.Description = reader.ReadElementContentAsString();
break;
case ItemSerializer.Quantity:
item.Quantity = reader.ReadElementContentAsInt();
break;
case ItemSerializer.Amount:
item.Amount = reader.ReadElementContentAsDecimal();
break;
case ItemSerializer.Weight:
item.Weight = reader.ReadElementContentAsLong();
break;
case ItemSerializer.ShippingCost:
item.ShippingCost = reader.ReadElementContentAsDecimal();
break;
default:
SerializationHelper.SkipElement(reader);
break;
}
}
else
{
SerializationHelper.SkipNode(reader);
}
}
}