本文整理汇总了C#中System.Xml.XmlReader.MoveToContent方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.MoveToContent方法的具体用法?C# XmlReader.MoveToContent怎么用?C# XmlReader.MoveToContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.MoveToContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
public object Deserialize(XmlReader xmlReader)
{
XmlRootAttribute xmlRootAttribute = (XmlRootAttribute) _type.GetCustomAttributes(typeof(XmlRootAttribute), false).SingleOrDefault();
string rootElement = null == xmlRootAttribute
? _type.Name
: xmlRootAttribute.ElementName;
xmlReader.MoveToContent();
if (xmlReader.LocalName != rootElement)
{
throw new XmlException("Unexpected element");
}
object res = DeserializeCheckedElement(xmlReader, _type);
// skip end tag
while (xmlReader.Read())
{
xmlReader.MoveToContent();
}
if (! xmlReader.EOF)
{
throw new XmlException("Invalid xml content");
}
return res;
}
示例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: ReadXml
internal static ResolveCriteria ReadXml (XmlReader reader, DiscoveryVersion version)
{
if (reader == null)
throw new ArgumentNullException ("reader");
var ret = new ResolveCriteria ();
reader.MoveToContent ();
if (!reader.IsStartElement ("ResolveType", version.Namespace) || reader.IsEmptyElement)
throw new XmlException ("Non-empty ResolveType element is expected");
reader.ReadStartElement ("ResolveType", version.Namespace);
// standard members
reader.MoveToContent ();
ret.Address = EndpointAddress.ReadFrom (version.MessageVersion.Addressing, reader);
// non-standard members
for (reader.MoveToContent (); !reader.EOF && reader.NodeType != XmlNodeType.EndElement; reader.MoveToContent ()) {
if (reader.NamespaceURI == SerializationNS) {
switch (reader.LocalName) {
case "Duration":
ret.Duration = (TimeSpan) reader.ReadElementContentAs (typeof (TimeSpan), null);
break;
}
}
else
ret.Extensions.Add (XElement.Load (reader));
}
reader.ReadEndElement ();
return ret;
}
示例4: ReadXml
public override void ReadXml(XmlReader reader)
{
reader.MoveToContent();
if (reader.AttributeCount == 0)
throw new MissingXmlAttributeException(@"Missing XML attribute ""value"".");
Name = reader["name"];
if (reader.IsEmptyElement)
{
reader.ReadEndElement();
return;
}
if (reader.ReadToDescendant(ChildXmlTag))
{
while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == ChildXmlTag)
{
reader.ReadStartElement();
reader.MoveToContent();
IilParameter p = IilParameter.fromString(reader.LocalName);
p.ReadXml(reader);
Parameters.Add(p);
reader.ReadEndElement();
}
}
reader.ReadEndElement();
//reader.Read();
}
示例5: ReadXml
public void ReadXml(XmlReader reader)
{
reader.MoveToContent();
var empty = reader.IsEmptyElement;
reader.ReadStartElement();
if (!empty)
{
while (reader.MoveToContent() == XmlNodeType.Element)
{
if (reader.Name == @"ProductName" && !reader.IsEmptyElement)
{
ProductName = reader.ReadElementString();
}
else if (reader.Name == @"GlyphColor" && !reader.IsEmptyElement)
{
GlyphColor = ParseColor(reader.ReadElementString());
}
else
{
// consume the bad element and skip to next sibling or the parent end element tag
reader.ReadOuterXml();
}
}
reader.MoveToContent();
reader.ReadEndElement();
}
}
示例6: GetFeed
public static IFeed GetFeed(Uri url, XmlReader reader) {
reader.MoveToContent();
string language = string.Empty;
FeedType feedType;
string namespaceUri = reader.NamespaceURI;
if(reader.LocalName.Equals("RDF") &&
reader.NamespaceURI.Equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) {
feedType = FeedType.Rdf;
reader.Read();
reader.MoveToContent();
} else if(reader.LocalName.Equals("rss")) {
feedType = FeedType.Rss;
do {
reader.Read();
reader.MoveToContent();
} while(!reader.LocalName.Equals("channel") && !reader.LocalName.Equals("rss"));
} else if(reader.NamespaceURI.Equals("http://purl.org/atom/ns#") && reader.LocalName.Equals("feed")) {
if(reader.MoveToAttribute("version") && reader.Value.Equals("0.3")) {
feedType = FeedType.Atom;
language = reader.XmlLang;
reader.MoveToElement();
} else {
throw new ApplicationException(string.Format("Unsupported Atom Version {0}", reader.Value));
}
} else if(reader.NamespaceURI.Equals("http://www.w3.org/2005/Atom") && reader.LocalName.Equals("feed")) {
feedType = FeedType.Atom;
language = reader.XmlLang;
} else {
throw new ApplicationException("Unknown Xml Dialect");
}
return PopulateFeed(url, reader, namespaceUri, feedType, language);
}
示例7: ProcessItem
private void ProcessItem(XmlReader reader)
{
reader.MoveToContent();
Material tmpMaterial = new Material();
tmpMaterial.name = reader.GetAttribute("displayname");
tmpMaterial.type = reader.GetAttribute("type");
if (reader.ReadToFollowing("ambient"))
{
reader.MoveToContent();
tmpMaterial.ambient.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
tmpMaterial.ambient.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
tmpMaterial.ambient.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
tmpMaterial.ambient.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
}
if (reader.ReadToFollowing("specular"))
{
reader.MoveToContent();
tmpMaterial.specular.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
tmpMaterial.specular.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
tmpMaterial.specular.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
tmpMaterial.specular.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
}
if (reader.ReadToFollowing("diffuse"))
{
reader.MoveToContent();
tmpMaterial.diffuse.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
tmpMaterial.diffuse.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
tmpMaterial.diffuse.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
tmpMaterial.diffuse.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
}
if (reader.ReadToFollowing("emissive"))
{
reader.MoveToContent();
tmpMaterial.emission.R = (float)Convert.ToDouble(reader.GetAttribute("r").Replace(".", ","));
tmpMaterial.emission.G = (float)Convert.ToDouble(reader.GetAttribute("g").Replace(".", ","));
tmpMaterial.emission.B = (float)Convert.ToDouble(reader.GetAttribute("b").Replace(".", ","));
tmpMaterial.emission.A = (float)Convert.ToDouble(reader.GetAttribute("a").Replace(".", ","));
}
if (reader.ReadToFollowing("shininess"))
{
reader.MoveToContent();
tmpMaterial.shininess = (float)Convert.ToDouble(reader.GetAttribute("value").Replace(".", ","));
}
if (reader.ReadToFollowing("texture"))
{
reader.MoveToContent();
tmpMaterial.LoadTexture(reader.GetAttribute("file"));
}
this.lstMaterial.Add(tmpMaterial);
}
示例8: ReadPinboardXml
private static PinboardData ReadPinboardXml(XmlReader reader)
{
PinboardData data = new PinboardData();
reader.ReadStartElement("Pinboard");
reader.MoveToContent();
data.ScreenRectInfo = ReadRectangleXml(reader);
data.RectInfos = ReadRectanglesXml(reader);
reader.ReadEndElement();
reader.MoveToContent();
return data;
}
示例9: CanRead
public static bool CanRead (XmlReader xmlReader)
{
xmlReader.MoveToContent ();
return xmlReader.NodeType == XmlNodeType.Element &&
xmlReader.LocalName == "discovery" &&
xmlReader.NamespaceURI == Namespace;
}
示例10: ReadXml
public void ReadXml(XmlReader reader)
{
int count;
reader.MoveToContent();
int.TryParse(reader["ChildrenCount"], out count);
reader.ReadStartElement("Professionbuddy");
PrioritySelector ps = (PrioritySelector)DecoratedChild;
for (int i = 0; i < count; i++)
{
Type type = Type.GetType("HighVoltz.Composites." + reader.Name);
if (type != null)
{
IPBComposite comp = (IPBComposite)Activator.CreateInstance(type);
if (comp != null)
{
comp.ReadXml(reader);
ps.AddChild((Composite)comp);
}
}
else
{
Professionbuddy.Err("PB:Failed to load type {0}", type);
}
}
if (reader.NodeType == XmlNodeType.EndElement)
reader.ReadEndElement();
}
示例11: ReadXml
public void ReadXml(XmlReader reader)
{
reader.MoveToContent();
Repeat = Convert.ToInt32(reader["Repeat"], CultureInfo.InvariantCulture);
if (reader.IsEmptyElement) {
reader.ReadStartElement();
return;
}
reader.ReadStartElement();
while (!reader.EOF) {
if (reader.IsStartElement()) {
switch (reader.Name) {
case "Frames":
ReadFramesXml(reader);
break;
default:
reader.Skip();
break;
}
}
else if (reader.NodeType == XmlNodeType.EndElement) {
reader.ReadEndElement();
break;
}
else
reader.Read();
}
}
示例12: ReadXml
public void ReadXml(XmlReader reader)
{
reader.MoveToContent();
DefaultAnimation = reader["DefaultAnimation"];
if (reader.IsEmptyElement) {
reader.ReadStartElement();
return;
}
reader.ReadStartElement();
while (!reader.EOF) {
if (reader.IsStartElement()) {
switch (reader.Name) {
case "Activity":
XmlActivityElement activity = new XmlActivityElement();
activity.ReadXml(reader);
Activities.Add(activity);
break;
default:
reader.Skip();
break;
}
}
else if (reader.NodeType == XmlNodeType.EndElement) {
reader.ReadEndElement();
break;
}
else
reader.Read();
}
}
示例13: ReadXml
public static KeyValuePair<string, Property> ReadXml(XmlReader reader)
{
var key = reader.GetAttribute("Key");
var type = reader.GetAttribute("Type");
reader.MoveToElement();
reader.ReadStartElement("PropertyEntry");
Property value = null;
try
{
var t = Type.GetType(type);
value = (Property)GetSerializer(t).Deserialize(reader);
}
catch (Exception ex)
{
Console.WriteLine("Deserialization failed: " + ex.Message);
Console.WriteLine("Property Key: " + key);
Console.WriteLine("Property Type Qualified Name: " + type);
Console.WriteLine("Stacktrace: " + ex.StackTrace);
}
reader.ReadEndElement();
reader.MoveToContent();
if (value == null)
throw new Exception();
return new KeyValuePair<string, Property>(key, value);
}
示例14: ReadXml
/// <summary>Generates an object from its XML representation.</summary>
/// <param name="reader">The <see cref="T:System.Xml.XmlReader" /> stream from which the object is
/// deserialized.</param>
public override void ReadXml(XmlReader reader)
{
reader.MoveToContent();
reader.ReadStartElement();
Descriptor = Xml.Read<Descriptor>(reader);
Root = Xml.Read<Measure>(reader);
}
示例15: CanRead
public override bool CanRead (XmlReader reader)
{
if (reader == null)
throw new ArgumentNullException ("reader");
reader.MoveToContent ();
return reader.LocalName == "service" && reader.NamespaceURI == Version;
}