예제 #1
0
        private void ParseCurrentFeedCount()
        {
            if (this.feed == null)
            {
                throw new InvalidOperationException(Strings.AtomParser_FeedCountNotUnderFeed);
            }

            if (this.feed.Count.HasValue)
            {
                throw new InvalidOperationException(Strings.AtomParser_ManyFeedCounts);
            }

            long countValue;

            if (!long.TryParse(MaterializeAtom.ReadElementString(this.reader, true), System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out countValue))
            {
                throw new FormatException(Strings.MaterializeFromAtom_CountFormatError);
            }

            if (countValue < 0)
            {
                throw new FormatException(Strings.MaterializeFromAtom_CountFormatError);
            }

            this.feed.Count = countValue;
        }
예제 #2
0
 internal string ReadCustomElementString()
 {
     Debug.Assert(
         this.kind == AtomDataKind.Custom,
         "this.kind == AtomDataKind.Custom -- otherwise caller shouldn't invoke ReadCustomElementString");
     return(MaterializeAtom.ReadElementString(this.reader, true));
 }
예제 #3
0
        internal virtual PrimitiveParserToken TokenizeFromXml(XmlReader reader)
        {
            string text = MaterializeAtom.ReadElementString(reader, true);

            if (text != null)
            {
                return(new TextPrimitiveParserToken(text));
            }
            return(null);
        }
예제 #4
0
        /// <summary>
        /// Create a parser token from xml feed
        /// </summary>
        /// <param name="reader">The xml reader</param>
        /// <remarks>The reader is expected to be placed at the beginning of the element, and after this method call, the reader will be placed
        /// at the EndElement, such that the next Element will be read in the next Read call.</remarks>
        /// <returns>token</returns>
        internal virtual PrimitiveParserToken TokenizeFromXml(XmlReader reader)
        {
            Debug.Assert(reader.NodeType == XmlNodeType.Element, "Reader at element");
            string elementString = MaterializeAtom.ReadElementString(reader, true);

            if (elementString != null)
            {
                return(new TextPrimitiveParserToken(elementString));
            }

            return(null);
        }