Пример #1
0
        /// <summary>
        /// Validates that the stream contains a valid feed item.
        /// </summary>
        public override void Start()
        {
            _reader.MoveToContent();

            if (!AtomHelper.IsAtomElement(_reader, FormatterConstants.AtomPubFeedElementName))
            {
                throw new InvalidOperationException("Not a valid ATOM feed.");
            }
        }
Пример #2
0
        /// <summary>
        /// Traverses through the feed and returns when it arrives at the necessary element.
        /// </summary>
        /// <returns>bool detecting whether or not there is more elements to be read.</returns>
        public override bool Next()
        {
            // User did not read the node.
            if (_currentType != ReaderItemType.BOF && !_currentNodeRead)
            {
                _reader.Skip();
            }

            do
            {
                _currentEntryWrapper = null;
                _liveEntity          = null;
                if (AtomHelper.IsAtomElement(_reader, FormatterConstants.AtomPubEntryElementName) ||
                    AtomHelper.IsAtomTombstone(_reader, FormatterConstants.AtomDeletedEntryElementName))
                {
                    _currentType     = ReaderItemType.Entry;
                    _currentNodeRead = false;
                    return(true);
                }
                else if (AtomHelper.IsSyncElement(_reader, FormatterConstants.ServerBlobText))
                {
                    _currentType     = ReaderItemType.SyncBlob;
                    _currentNodeRead = false;
                    return(true);
                }
                else if (AtomHelper.IsSyncElement(_reader, FormatterConstants.MoreChangesAvailableText))
                {
                    _currentType     = ReaderItemType.HasMoreChanges;
                    _currentNodeRead = false;
                    return(true);
                }
            } while (_reader.Read());

            this._currentType = ReaderItemType.EOF;

            return(false);
        }