Exemplo n.º 1
0
        public static IEnumerable <XElement> Stream(this XElement source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            StreamLoader loader = source.Annotation <StreamLoader>();

            if (loader == null)
            {
                throw new InvalidOperationException("No stream associated with the element.");
            }
            return(loader.Stream(source));
        }
Exemplo n.º 2
0
        public static XElement LoadStream(XmlReader reader, XName rootName, params XName[] streamNames)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }
            if (rootName == null)
            {
                throw new ArgumentNullException(nameof(rootName));
            }
            if (streamNames == null)
            {
                throw new ArgumentNullException(nameof(streamNames));
            }
            for (int i = 0; i < streamNames.Length; i++)
            {
                if (streamNames[i] == null)
                {
                    throw new ArgumentNullException("streamNames[" + i + "]");
                }
            }
            if (reader.MoveToContent() != XmlNodeType.Element)
            {
                throw new InvalidOperationException(string.Format("The reader should be on a node of type '{0}'.", XmlNodeType.Element));
            }
            XElement     source     = new XElement(rootName);
            StreamLoader loader     = new StreamLoader(reader, streamNames);
            XName        streamName = streamNames.Length > 0 ? streamNames[0] : null;

            loader.ReadElementUntil(source, streamName);
            if (streamName != null)
            {
                source.AddAnnotation(loader);
            }
            return(source);
        }
Exemplo n.º 3
0
 public StreamIterator(StreamLoader loader, int index, XElement source)
 {
     _loader     = loader;
     _index      = index;
     this.source = source;
 }