Create() public static method

public static Create ( Stream input ) : XmlReader
input Stream
return XmlReader
        /// <summary>
        /// Returns an <c>XmlReader</c> with feature informations.
        /// Use <c>XmlDocument.Load(XmlReader)</c> for obtain a <c>XmlDocument</c> to work.
        /// </summary>
        /// <param name="geometry"></param>
        /// <returns></returns>
        public XmlReader Write(IGeometry geometry)
        {
            byte[] data = GetBytes(geometry);
            using (Stream stream = new MemoryStream(data))
                Write(geometry, stream);
            Stream outStream = new MemoryStream(data);

#if PCL || NETSTANDARD1_6
            return(XmlTextReader.Create(outStream));
#else
            return(new XmlTextReader(outStream));
#endif
        }
Beispiel #2
0
        /// <summary>
        /// Parses a ClinVar file and return an enumeration object containing all the ClinVar objects
        /// that have been extracted
        /// </summary>
        private IEnumerable <ClinVarItem> GetItems()
        {
            using (var reader = GZipUtilities.GetAppropriateStreamReader(_clinVarXmlFileInfo.FullName))
                using (var xmlReader = XmlTextReader.Create(reader, new XmlReaderSettings {
                    DtdProcessing = DtdProcessing.Prohibit, IgnoreWhitespace = true
                }))
                {
                    string elementName = null;

                    //skipping the top level element to go down to its children
                    xmlReader.ReadToDescendant("ClinVarSet");

                    do
                    {
                        LiteXmlElement xmlElement = null;

                        switch (xmlReader.NodeType)
                        {
                        case XmlNodeType.Element:                         // The node is an element.
                            elementName = xmlReader.Name;
                            xmlElement  = ParseXmlElement(xmlReader);
                            break;

                        case XmlNodeType.EndElement:                         //Display the end of the element.
                            // Release set is the top level element we skipped. So, we will encounter this mismatch.
                            if (xmlReader.Name != "ReleaseSet" && xmlReader.Name != elementName)
                            {
                                throw new InvalidDataException("WARNING!! encountered unexpected endElement tag:" + xmlReader.Name);
                            }
                            break;

                        default:
                            continue;
                        }

                        var clinVarItems = ExtractClinVarItems(xmlElement);

                        if (clinVarItems == null)
                        {
                            continue;
                        }

                        foreach (var clinVarItem in clinVarItems)
                        {
                            yield return(clinVarItem);
                        }
                    } while (xmlReader.Read());
                }
        }