/// <summary> /// parses a single error element /// </summary> /// <param name="reader">XmlReader positioned at the start of the status element</param> /// <param name="parser">the feedparser to be used</param> /// <returns>GDataBatchError</returns> public static GDataBatchError ParseBatchError(XmlReader reader, AtomFeedParser parser) { if (reader == null) { throw new System.ArgumentNullException("reader"); } object localname = reader.LocalName; GDataBatchError error = null; if (localname.Equals(parser.Nametable.BatchError)) { error = new GDataBatchError(); if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { localname = reader.LocalName; if (localname.Equals(parser.Nametable.BatchReason)) { error.Reason = Utilities.DecodedValue(reader.Value); } else if (localname.Equals(parser.Nametable.Type)) { error.Type = Utilities.DecodedValue(reader.Value); } else if (localname.Equals(parser.Nametable.BatchField)) { error.Field = Utilities.DecodedValue(reader.Value); } } } } return(error); }
/// <summary> /// reads the current positioned reader and creates a batchstatus element /// </summary> /// <param name="reader">XmlReader positioned at the start of the status element</param> /// <param name="parser">The Feedparser to be used</param> /// <returns>GDataBatchStatus</returns> public static GDataBatchStatus ParseBatchStatus(XmlReader reader, AtomFeedParser parser) { //Tracing.Assert(reader != null, "reader should not be null"); if (reader == null) { throw new ArgumentNullException("reader"); } GDataBatchStatus status = null; object localname = reader.LocalName; if (localname.Equals(parser.Nametable.BatchStatus)) { status = new GDataBatchStatus(); if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { localname = reader.LocalName; if (localname.Equals(parser.Nametable.BatchReason)) { status.Reason = Utilities.DecodedValue(reader.Value); } else if (localname.Equals(parser.Nametable.BatchContentType)) { status.ContentType = Utilities.DecodedValue(reader.Value); } else if (localname.Equals(parser.Nametable.BatchStatusCode)) { status.Code = int.Parse(Utilities.DecodedValue(reader.Value), CultureInfo.InvariantCulture); } } } reader.MoveToElement(); // FIX: THIS CODE SEEMS TO MAKE AN INFINITE LOOP WITH NextChildElement() int lvl = -1; // status can have one child element, errors while (Utilities.NextChildElement(reader, ref lvl)) { localname = reader.LocalName; if (localname.Equals(parser.Nametable.BatchErrors)) { GDataBatchError.ParseBatchErrors(reader, parser, status); } } } return(status); }