public void ReasonTest()
 {
     GDataBatchStatus target = new GDataBatchStatus(); // TODO: Initialize to an appropriate value
     string expected = "TestValue";            
     string actual;
     target.Reason = expected;
     actual = target.Reason;
     Assert.AreEqual(expected, actual);
 }
        /// <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;
        }
示例#5
0
        /// <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>
        /// <returns>GDataBatchStatus</returns>
        protected GDataBatchStatus ParseBatchStatus(XmlReader reader) 
        {
            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(this.nameTable.BatchStatus))
            {
                status = new GDataBatchStatus();
                if (reader.HasAttributes)
                {
                    while (reader.MoveToNextAttribute())
                    {
                        localname = reader.LocalName;
                        if (localname.Equals(this.nameTable.BatchReason))
                        {
                            status.Reason = Utilities.DecodedValue(reader.Value);
                        }
                        else if (localname.Equals(this.nameTable.BatchContentType))
                        {
                            status.ContentType = Utilities.DecodedValue(reader.Value); 
                        }
                        else if (localname.Equals(this.nameTable.BatchStatusCode))
                        {
                            status.Code = int.Parse(Utilities.DecodedValue(reader.Value), CultureInfo.InvariantCulture);
                        }
                    }
                }

                // FIX: THIS CODE SEEMS TO MAKE AN INFINITE LOOP WITH NextChildElement()
                //reader.MoveToElement();
                //status.Value = Utilities.DecodedValue(reader.ReadString());
                ////////////////////////////////////////////////////////////////////////

                // status can have one child element, errors
                // for now disabled, as this is currently not supported on the server
                // instead the errors come as encoded strings
                /*
                int lvl = -1;
                while(NextChildElement(reader, ref lvl))
                {
                    localname = reader.LocalName;

                    if (localname.Equals(this.nameTable.BatchErrors))
                    {
                        // author.Name = Utilities.DecodeString(Utilities.DecodedValue(reader.ReadString()));
                        status.Errors = ParseBatchErrors(reader); 
                    }
                }
                */
            }
            return status;
        }
示例#6
0
 public void StatusTest()
 {
     GDataBatchEntryData target = new GDataBatchEntryData(); // TODO: Initialize to an appropriate value
     GDataBatchStatus expected = new GDataBatchStatus();
     GDataBatchStatus actual;
     target.Status = expected;
     actual = target.Status;
     Assert.AreEqual(expected, actual);
 }
 public void CodeTest()
 {
     GDataBatchStatus target = new GDataBatchStatus(); // TODO: Initialize to an appropriate value
     int expected = 27; // TODO: Initialize to an appropriate value
     int actual;
     target.Code = expected;
     actual = target.Code;
     Assert.AreEqual(expected, actual);
 }
示例#8
0
        /// <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;
        }
示例#9
0
        /// <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;
        }