本文整理汇总了C#中XmlReader.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.Skip方法的具体用法?C# XmlReader.Skip怎么用?C# XmlReader.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.Skip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadObjectProperties
public static void ReadObjectProperties(XmlReader reader, object obj, PropertyConversionHandler handler = null)
{
// Build property lookup table
PropertyInfo[] props = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
Dictionary<string, PropertyInfo> propHash = new Dictionary<string, PropertyInfo>(props.Length);
foreach (var pi in props)
if (!Attribute.IsDefined(pi, typeof(XmlIgnoreAttribute), false))
propHash.Add(GetPropertyElementName(pi), pi);
while (reader.MoveToContent() == System.Xml.XmlNodeType.Element)
{
PropertyInfo pi;
if (propHash.TryGetValue(reader.LocalName, out pi))
{
if (IsStandardType(pi.PropertyType))
{
object value = null;
if (pi.PropertyType.IsEnum)
value = Enum.Parse(pi.PropertyType, reader.ReadElementContentAsString());
else
value = reader.ReadElementContentAs(pi.PropertyType, null);
if (handler != null)
handler(pi, obj, ref value);
pi.SetValue(obj, value, null);
}
else
{
ReadObject(reader, pi.GetValue(obj, null));
}
}
else
{
reader.Skip();
reader.MoveToContent();
}
}
}
示例2: ReadObject
public static void ReadObject(XmlReader reader, object obj, PropertyConversionHandler handler = null)
{
if (obj == null)
throw new ArgumentNullException("obj");
reader.MoveToContent();
if (obj is IXmlSerializable)
{
((IXmlSerializable)obj).ReadXml(reader);
}
else
{
object oVal = null;
string oName = GetAttributeValue(obj.GetType(), typeof(XmlRootAttribute), "ElementName", true, ref oVal) ? oVal.ToString() : obj.GetType().Name;
if (reader.LocalName != oName)
throw new XmlException("XML element name does not match object.");
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
reader.MoveToContent();
ReadObjectProperties(reader, obj, handler);
reader.ReadEndElement();
}
else
reader.Skip();
}
}
示例3: displayWarning
// DEBUG INFORMATION
// Method updates warning log and moves XML reader passed unknown elements
void displayWarning(XmlReader myReader,string elementName,string parentTag)
{
// Set warning flag and add details to error log
warning = true;
myLog += "\nFound in Jellyfish '" + jellyfishName + "':" +
"\nUnknown element found inside <"+parentTag+"> tag: <"+elementName+">\n";
// Reader skips this unrecognised element (and all child elements of this tag)
myReader.Skip();
}