示例#1
0
        public AtomFeed ReadFeed(XmlReader reader)
        {
            if (reader.ReadState != ReadState.Initial) {
            throw new InvalidOperationException();
              }

              AtomFeed feed = null;

              lock (_lock) {
            _nameTable = new AtomNameTable(reader.NameTable);

            if (reader.IsStartElement((string)_nameTable.LocalNameFeed, (string)_nameTable.NamespaceUriAtom)) {
              feed = ReadFeedInner(reader);
            }
              }

              if (feed == null) {
            throw new AtomFormatException("The document is not a feed document.");
              }

              return feed;
        }
示例#2
0
        public AtomDocument ReadDocument(XmlReader reader)
        {
            if (reader.ReadState != ReadState.Initial) {
            throw new InvalidOperationException();
              }

              AtomDocument doc = null;

              lock (_lock) {
            _nameTable = new AtomNameTable(reader.NameTable);

            if (reader.IsStartElement((string)_nameTable.LocalNameFeed, (string)_nameTable.NamespaceUriAtom)) {
              bool halt = RaiseDocumentTypeDetectedEvent(typeof(AtomFeed));
              if (halt) {
            throw new ArgumentException("Further processing fot AtomFeed was halted.");
              }
              doc = ReadFeedInner(reader);
            }
            else if (reader.IsStartElement((string)_nameTable.LocalNameEntry, (string)_nameTable.NamespaceUriAtom)) {
              bool halt = RaiseDocumentTypeDetectedEvent(typeof(AtomEntry));
              if (halt) {
            throw new ArgumentException("Further processing fot AtomEntry was halted.");
              }
              doc = ReadEntryInner(reader);
            }
              }

              if (doc == null) {
            throw new AtomFormatException("The document is neigher feed document nor entry document.");
              }

              return doc;
        }
示例#3
0
        public AtomEntry ReadEntry(XmlReader reader)
        {
            if (reader.ReadState != ReadState.Initial) {
            throw new InvalidOperationException();
              }

              AtomEntry entry = null;

              lock (_lock) {
            _nameTable = new AtomNameTable(reader.NameTable);

            if (reader.IsStartElement((string)_nameTable.LocalNameEntry, (string)_nameTable.NamespaceUriAtom)) {
              entry = ReadEntryInner(reader);
            }
              }

              if (entry == null) {
            throw new AtomFormatException("The document is not a entry document.");
              }

              return entry;
        }