/// <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); }
/// <summary> /// parses the current position in the xml reader and fills /// the provided GDataEntryBatch property on the entry object /// </summary> /// <param name="reader">the xmlreader positioned at a batch element</param> /// <param name="entry">the atomentry object to fill in</param> protected void ParseBatch(XmlReader reader, AtomEntry entry) { if (reader == null) { throw new ArgumentNullException("reader"); } if (entry == null) { throw new ArgumentNullException("entry"); } if (IsCurrentNameSpace(reader, BaseNameTable.gBatchNamespace)) { object elementName = reader.LocalName; if (entry.BatchData == null) { entry.BatchData = new GDataBatchEntryData(); } GDataBatchEntryData batch = entry.BatchData; if (elementName.Equals(this.nameTable.BatchId)) { batch.Id = Utilities.DecodedValue(reader.ReadString()); } else if (elementName.Equals(this.nameTable.BatchOperation)) { batch.Type = ParseOperationType(reader); } else if (elementName.Equals(this.nameTable.BatchStatus)) { batch.Status = GDataBatchStatus.ParseBatchStatus(reader, this); } else if (elementName.Equals(this.nameTable.BatchInterrupt)) { batch.Interrupt = GDataBatchInterrupt.ParseBatchInterrupt(reader, this); } else { Tracing.TraceInfo("got an unknown batch element: " + elementName.ToString()); // default extension parsing ParseExtensionElements(reader, entry); } } }
/// <summary> /// parses a list of errors /// </summary> /// <param name="reader">XmlReader positioned at the start of the status element</param> /// <param name="status">the batch status element to add the errors tohe</param> /// <param name="parser">the feedparser to be used</param> public static void ParseBatchErrors(XmlReader reader, AtomFeedParser parser, GDataBatchStatus status) { if (reader == null) { throw new System.ArgumentNullException("reader"); } object localname = reader.LocalName; if (localname.Equals(parser.Nametable.BatchErrors)) { int lvl = -1; while (Utilities.NextChildElement(reader, ref lvl)) { localname = reader.LocalName; if (localname.Equals(parser.Nametable.BatchError)) { status.Errors.Add(ParseBatchError(reader, parser)); } } } return; }