Exemple #1
0
        /// <summary>
        /// Strip the next publication off of the top of the string.
        /// </summary>
        /// <param name="MedlineData">A string containing the Medline data, passed
        /// by reference so that the first publication can be stripped off</param>
        /// <param name="publication">A publication that will contain the next publication in the Medline stream</param>
        /// <returns>True if a publication was read, false otherwise</param>
        private static bool GetNextPublication(ref string MedlineData, out Publication publication, PublicationTypes pubTypes)
        {
            Publication PublicationToWrite = new Publication();

            string       line;
            StringReader reader = new StringReader(MedlineData);

            // Skip past any blank lines at the top of the publication
            // Return null if there are no more publications
            line = reader.ReadLine();
            if (line == null)
            {
                // There are no more publications
                publication = new Publication();
                return(false);
            }

            else if (line.Trim().Length == 0)
            {
                // There are blank lines to skip. Read each line, and if it's blank
                // advance MedlineData past it.
                while (line.Trim().Length == 0)
                {
                    MedlineData = reader.ReadToEnd();
                    reader      = new StringReader(MedlineData);
                    line        = reader.ReadLine();
                    if (line == null)
                    {
                        publication = new Publication();
                        return(false);
                    }
                }
                // MedlineData is now set to the first line after the blanks
            }
            // Never mind, set reader back to the beginning of MedlineData
            reader = new StringReader(MedlineData);

            // Read the next line, and keep reading until it hits a blank line
            // or the end of the file
            while (((line = reader.ReadLine()) != null) && (line.Trim().Length != 0))
            {
                // Take each following line that starts with a space and add them
                // to the end of the current line
                while (reader.Peek() == ' ')
                {
                    line = line + " " + reader.ReadLine().Trim();
                }
                Publications.ProcessMedlineTag(ref PublicationToWrite, line, pubTypes);
            }

            MedlineData = reader.ReadToEnd();

            publication = PublicationToWrite;
            return(true);
        }