本文整理汇总了C#中System.Xml.XmlReader.ReadElementContentAsLong方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadElementContentAsLong方法的具体用法?C# XmlReader.ReadElementContentAsLong怎么用?C# XmlReader.ReadElementContentAsLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadElementContentAsLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeserializePropertyElement
protected override void DeserializePropertyElement(XmlReader reader)
{
if (reader == null) throw new ArgumentNullException ("reader");
if (reader.NamespaceURI == Schemas.UpnpSchema) {
switch (reader.LocalName) {
case "storageTotal":
StorageTotal = reader.ReadElementContentAsLong ();
break;
case "storageUsed":
StorageUsed = reader.ReadElementContentAsLong ();
break;
case "storageFree":
StorageFree = reader.ReadElementContentAsLong ();
break;
case "storageMedium":
StorageMedium = reader.ReadString ();
break;
default:
base.DeserializePropertyElement (reader);
break;
}
} else {
base.DeserializePropertyElement (reader);
}
}
示例2: ReadXml
public void ReadXml(XmlReader reader)
{
while (!reader.EOF)
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case EPUB3SubVersionElementName:
EPubV3SubStandard standard;
string elementContent = reader.ReadElementContentAsString();
if (!Enum.TryParse(elementContent, true, out standard))
{
throw new InvalidDataException(string.Format("Invalid epub standard version passed : {0}", elementContent));
}
_v3SubStandard = standard;
continue;
case GenerateV2CompatibleTOCElementName:
_generateV2CompatibleTOC = reader.ReadElementContentAsBoolean();
continue;
case HTMLFileMaxSizeAllowedElementName:
HTMLFileMaxSize = (ulong)reader.ReadElementContentAsLong();
continue;
}
}
reader.Read();
}
}
示例3: 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);
}
}
}
示例4: DeserializePropertyElement
protected override void DeserializePropertyElement(XmlReader reader)
{
if (reader == null) throw new ArgumentNullException ("reader");
if (reader.NamespaceURI == Schemas.UpnpSchema && reader.Name == "storageUsed") {
StorageUsed = reader.ReadElementContentAsLong ();
} else {
base.DeserializePropertyElement (reader);
}
}
示例5: Read
/// <summary>
///
/// </summary>
/// <param name="reader"></param>
/// <param name="item"></param>
internal static void Read(XmlReader reader, Item item)
{
if (reader.IsEmptyElement)
{
XMLParserUtils.SkipNode(reader);
return;
}
reader.ReadStartElement(ItemSerializer.Item);
reader.MoveToContent();
while (!reader.EOF)
{
if (XMLParserUtils.IsEndElement(reader, ItemSerializer.Item))
{
XMLParserUtils.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:
XMLParserUtils.SkipElement(reader);
break;
}
}
else
{
XMLParserUtils.SkipNode(reader);
}
}
}
示例6: ReadXml
public void ReadXml(XmlReader reader)
{
if (reader == null)
throw new ArgumentNullException(nameof(reader));
reader.ReadStartElement();
var dayTicks = reader.ReadElementContentAsLong(nameof(Day), string.Empty);
Day = new DateTime(dayTicks);
Attendances = DeserializeAttendances(reader);
reader.ReadEndElement();
}
示例7: ReadXml
public bool ReadXml(XmlReader reader, string password)
{
bool changed = false;
Guid id;
#if NETFX_4
if (Guid.TryParse(reader.GetAttribute("id"), out id) == true)
{
Id = id;
}
#endif
#if NETFX_3
try
{
id = new Guid(reader.GetAttribute("id"));
Id = id;
}
catch (Exception) { }
#endif
string authenticatorType = reader.GetAttribute("type");
if (string.IsNullOrEmpty(authenticatorType) == false)
{
Type type = typeof(Authenticator).Assembly.GetType(authenticatorType, false, true);
this.AuthenticatorData = Activator.CreateInstance(type) as Authenticator;
}
//string encrypted = reader.GetAttribute("encrypted");
//if (string.IsNullOrEmpty(encrypted) == false)
//{
// // read the encrypted text from the node
// string data = reader.ReadElementContentAsString();
// // decrypt
// Authenticator.PasswordTypes passwordType;
// data = Authenticator.DecryptSequence(data, encrypted, password, out passwordType);
// using (MemoryStream ms = new MemoryStream(Authenticator.StringToByteArray(data)))
// {
// reader = XmlReader.Create(ms);
// ReadXml(reader, password);
// }
// this.PasswordType = passwordType;
// this.Password = password;
// return;
//}
reader.MoveToContent();
if (reader.IsEmptyElement)
{
reader.Read();
return changed;
}
reader.Read();
while (reader.EOF == false)
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case "name":
Name = reader.ReadElementContentAsString();
break;
case "created":
long t = reader.ReadElementContentAsLong();
t += Convert.ToInt64(new TimeSpan(new DateTime(1970, 1, 1).Ticks).TotalMilliseconds);
t *= TimeSpan.TicksPerMillisecond;
Created = new DateTime(t).ToLocalTime();
break;
case "autorefresh":
_autoRefresh = reader.ReadElementContentAsBoolean();
break;
case "allowcopy":
_allowCopy= reader.ReadElementContentAsBoolean();
break;
case "copyoncode":
_copyOnCode = reader.ReadElementContentAsBoolean();
break;
case "hideserial":
_hideSerial = reader.ReadElementContentAsBoolean();
break;
case "skin":
_skin = reader.ReadElementContentAsString();
break;
case "hotkey":
_hotkey = new WinAuth.HotKey();
_hotkey.ReadXml(reader);
break;
case "authenticatordata":
try
//.........这里部分代码省略.........
示例8: ReadXML
// XML related things
void ReadXML(XmlReader xml)
{
xml.ReadStartElement("server");
while (xml.Read())
{
if (xml.NodeType != XmlNodeType.Element)
continue;
switch (xml.Name)
{
case "name":
name = xml.ReadElementContentAsString();
break;
case "executable":
executable = xml.ReadElementContentAsString();
break;
case "parameters":
parameters = xml.ReadElementContentAsString();
break;
case "ip":
ipaddr = xml.ReadElementContentAsString();
break;
case "port":
port = (ushort) xml.ReadElementContentAsInt();
break;
case "affinity":
ProcessAffinity = xml.ReadElementContentAsLong();
break;
case "query":
ReadQuery(xml);
break;
case "timer":
TimingData = new TimerData(xml.ReadSubtree(), this);
break;
}
}
}
示例9: ReadXml
public bool ReadXml(XmlReader reader, string password = null)
{
// decode the password type
string encrypted = reader.GetAttribute("encrypted");
PasswordTypes passwordType = DecodePasswordTypes(encrypted);
this.PasswordType = passwordType;
if (passwordType != PasswordTypes.None)
{
// read the encrypted text from the node
this.EncryptedData = reader.ReadElementContentAsString();
return Unprotect(password);
//// decrypt
//try
//{
// string data = Authenticator.DecryptSequence(this.EncryptedData, passwordType, password);
// using (MemoryStream ms = new MemoryStream(Authenticator.StringToByteArray(data)))
// {
// reader = XmlReader.Create(ms);
// this.ReadXml(reader, password);
// }
//}
//catch (EncrpytedSecretDataException)
//{
// this.RequiresPassword = true;
// throw;
//}
//finally
//{
// this.PasswordType = passwordType;
//}
}
reader.MoveToContent();
if (reader.IsEmptyElement)
{
reader.Read();
return false;
}
reader.Read();
while (reader.EOF == false)
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case "lastservertime":
LastServerTime = reader.ReadElementContentAsLong();
break;
case "servertimediff":
ServerTimeDiff = reader.ReadElementContentAsLong();
break;
case "secretdata":
SecretData = reader.ReadElementContentAsString();
break;
default:
if (ReadExtraXml(reader, reader.Name) == false)
{
reader.Skip();
}
break;
}
}
else
{
reader.Read();
break;
}
}
// check if we need to sync, or if it's been a day
if (this is HOTPAuthenticator)
{
// no time sync
return true;
}
else if (ServerTimeDiff == 0 || LastServerTime == 0 || LastServerTime < DateTime.Now.AddHours(-24).Ticks)
{
Sync();
return true;
}
else
{
return false;
}
}
示例10: LoadXml
public void LoadXml(XmlReader r)
{
//<Data>
// <Series>
// <id>...</id>
// etc.
// </Series>
// <Episode>
// <id>...</id>
// blah blah
// </Episode>
// <Episode>
// <id>...</id>
// blah blah
// </Episode>
// ...
//</Data>
try
{
r.Read();
if (r.Name != "Series")
return;
r.Read();
while (!r.EOF)
{
if ((r.Name == "Series") && (!r.IsStartElement()))
break;
if (r.Name == "id")
this.TVDBCode = r.ReadElementContentAsInt();
else if (r.Name == "SeriesName")
this.Name = XMLHelper.ReadStringFixQuotesAndSpaces(r);
else if (r.Name == "lastupdated")
this.Srv_LastUpdated = r.ReadElementContentAsLong();
else if ((r.Name == "Language") || (r.Name == "language"))
this.Language = r.ReadElementContentAsString();
else if (r.Name == "TimeZone")
this.ShowTimeZone = r.ReadElementContentAsString();
else if (r.Name == "Airs_Time")
{
this.AirsTime = DateTime.Parse("20:00");
try
{
string theTime = r.ReadElementContentAsString();
if (!string.IsNullOrEmpty(theTime))
{
this.Items["Airs_Time"] = theTime;
DateTime airsTime;
if (DateTime.TryParse(theTime, out airsTime) |
DateTime.TryParse(theTime.Replace('.', ':'), out airsTime))
this.AirsTime = airsTime;
else
this.AirsTime = null;
}
}
catch (FormatException)
{
}
}
else if (r.Name == "FirstAired")
{
string theDate = r.ReadElementContentAsString();
try
{
this.FirstAired = DateTime.ParseExact(theDate, "yyyy-MM-dd", new System.Globalization.CultureInfo(""));
this.Items["FirstAired"] = this.FirstAired.Value.ToString("yyyy-MM-dd");
this.Items["Year"] = this.FirstAired.Value.ToString("yyyy");
}
catch
{
this.FirstAired = null;
this.Items["FirstAired"] = "";
this.Items["Year"] = "";
}
}
else
{
string name = r.Name;
this.Items[name] = r.ReadElementContentAsString();
}
// r->ReadOuterXml(); // skip
} // while
} // try
catch (XmlException e)
{
string message = "Error processing data from TheTVDB for a show.";
if (this.TVDBCode != -1)
message += "\r\nTheTVDB Code: " + this.TVDBCode;
if (!string.IsNullOrEmpty(this.Name))
message += "\r\nName: " + this.Name;
if (!string.IsNullOrEmpty(this.Language))
message += "\r\nLanguage: \"" + this.Language + "\"";
message += "\r\n" + e.Message;
MessageBox.Show(message, "TVRename", MessageBoxButtons.OK, MessageBoxIcon.Error);
//.........这里部分代码省略.........
示例11: Read
internal void Read(XmlReader reader)
{
AtomFeed inferredRelationship;
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Attribute:
break;
case XmlNodeType.CDATA:
break;
case XmlNodeType.Comment:
break;
case XmlNodeType.Document:
break;
case XmlNodeType.DocumentFragment:
break;
case XmlNodeType.DocumentType:
break;
case XmlNodeType.Element:
switch (reader.LocalName)
{
case "title":
typeName = reader.ReadElementContentAsString();
foreach (var e in Entries)
{
e.TypeName = typeName;
}
break;
case "count":
this.Count = reader.ReadElementContentAsLong();
break;
case "link":
if (reader.GetAttribute("rel") == "next")
NextLink = new Uri(reader.GetAttribute("href"));
break;
case "inline":
inferredRelationship = new AtomFeed();
inferredRelationship.Read(reader);
InferredRelationships.Add(inferredRelationship.typeName, inferredRelationship);
break;
case "entry":
AtomEntry entry = new AtomEntry();
entry.TypeName = typeName;
entry.Read(reader);
Entries.Add(entry);
break;
default:
break;
}
break;
case XmlNodeType.EndElement:
break;
case XmlNodeType.EndEntity:
break;
case XmlNodeType.Entity:
break;
case XmlNodeType.EntityReference:
break;
case XmlNodeType.None:
break;
case XmlNodeType.Notation:
break;
case XmlNodeType.ProcessingInstruction:
break;
case XmlNodeType.SignificantWhitespace:
break;
case XmlNodeType.Text:
break;
case XmlNodeType.Whitespace:
break;
case XmlNodeType.XmlDeclaration:
break;
default:
break;
}
}
}
示例12: ReadXmlv2
public static Authenticator ReadXmlv2(XmlReader reader, string password = null)
{
Authenticator authenticator = null;
string authenticatorType = reader.GetAttribute("type");
if (string.IsNullOrEmpty(authenticatorType) == false)
{
authenticatorType = authenticatorType.Replace("WindowsAuthenticator.", "WinAuth.");
Type type = System.Reflection.Assembly.GetExecutingAssembly().GetType(authenticatorType, false, true);
authenticator = Activator.CreateInstance(type) as Authenticator;
}
if (authenticator == null)
{
authenticator = new BattleNetAuthenticator();
}
reader.MoveToContent();
if (reader.IsEmptyElement)
{
reader.Read();
return null;
}
reader.Read();
while (reader.EOF == false)
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case "servertimediff":
authenticator.ServerTimeDiff = reader.ReadElementContentAsLong();
break;
//case "restorecodeverified":
// authenticator.RestoreCodeVerified = reader.ReadElementContentAsBoolean();
// break;
case "secretdata":
string encrypted = reader.GetAttribute("encrypted");
string data = reader.ReadElementContentAsString();
PasswordTypes passwordType = DecodePasswordTypes(encrypted);
if (passwordType != PasswordTypes.None)
{
// this is an old version so there is no hash
data = DecryptSequence(data, passwordType, password, null);
}
authenticator.PasswordType = PasswordTypes.None;
authenticator.SecretData = data;
break;
default:
if (authenticator.ReadExtraXml(reader, reader.Name) == false)
{
reader.Skip();
}
break;
}
}
else
{
reader.Read();
break;
}
}
return authenticator;
}
示例13: DoRead
protected override Object DoRead(XmlReader reader)
{
return reader.ReadElementContentAsLong();
}
示例14: ReadAddressDataPairs
private static List<AddressDataPair> ReadAddressDataPairs(XmlReader reader)
{
List<AddressDataPair> addressDataPairList = new List<AddressDataPair>();
while (reader.Read())
{
reader.MoveToContent();
if (reader.LocalName.Equals("AddressDataPair"))
{
AddressDataPair addressDataPair = new AddressDataPair();
List<byte> byteList = new List<byte>();
while (reader.Read())
{
reader.MoveToContent();
if (reader.LocalName.Equals("Address"))
{
addressDataPair.m_Address = (uint)(reader.ReadElementContentAsLong());
}
else if (reader.LocalName.Equals("Data"))
{
while (reader.Read())
{
reader.MoveToContent();
if (reader.LocalName.Equals("Byte"))
{
byteList.Add((byte)reader.ReadElementContentAsLong());
}
else
{
addressDataPair.m_Data = byteList.ToArray();
addressDataPairList.Add(addressDataPair);
break;
}
}
}
else
break;
}
}
else
break;
}
return addressDataPairList;
}
示例15: ObjectEntry
internal ObjectEntry(XmlReader reader, string searchPrefix, string delimiter)
{
if (reader.IsEmptyElement)
throw new Exception("Expected a non-empty <Contents> element.");
reader.ReadStartElement("Contents");
this.Key = reader.ReadElementContentAsString("Key", "");
this.LastModified = reader.ReadElementContentAsDateTime("LastModified", "");
this.ETag = reader.ReadElementContentAsString("ETag", "");
this.Size = reader.ReadElementContentAsLong("Size", "");
// this tag may be omitted if you don't have permission to view the owner
if (reader.Name == "Owner")
this.Owner = new Identity(reader);
// this element is meaningless
if (reader.Name == "StorageClass")
reader.Skip();
reader.ReadEndElement();
this.Name = Key;
if (!string.IsNullOrEmpty(searchPrefix))
this.Name = Name.Substring(searchPrefix.Length);
}