Parse() public method

Thrown when...
public Parse ( ) : void
return void
コード例 #1
0
        /// <summary>
        /// Parse a vocabulary from a specified input stream.
        /// </summary>
        /// <param name="prop">The property name in Property class identifying the vocabulary to parse.</param>
        /// <param name="inputStream">The input stream of the vocabulary to parse.</param>
        /// <returns>Return a VocabularyParser containing the parsed vocabulary model.</returns>
        /// <exception cref="InitializationException">Throws when...</exception>
        private VocabularyParser ParseVocabularyFromStream(String prop, Stream inputStream)
        {
            VocabularyParser vocabularyParser;
            try
            {
                vocabularyParser = new VocabularyParser(inputStream);
            }
            catch (ArgumentNullException ex)
            {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new InvalidOperationException("Can not instantiate VocabularyParser(Stream stream)"));

            }

            try
            {
                vocabularyParser.Parse();

            }
            catch (Exception ex) {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not parse document in property: " + prop));

            }

            inputStream.Close();
            return vocabularyParser;
        }
コード例 #2
0
        /// <summary>
        /// Parse a vocabulary from a specified path.
        /// </summary>
        /// <param name="prop">The property name in Property class identifying the vocabulary to parse.</param>
        /// <param name="path">The path of the vocabulary to parse.</param>
        /// <returns>Return a VocabularyParser containing the parsed vocabulary model.</returns>
        /// <exception cref="InitializationException">Throws when...</exception>
        private VocabularyParser ParseVocabularyFromPath(String prop, String path)
        {
            VocabularyParser vocabularyParser;
            FileStream stream = null;

            try
            {
                stream = new FileStream(path, FileMode.Open, FileAccess.Read);

            }
            catch (IOException ex) {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new ArgumentException("Can not open " + prop + " : " + path));
            }

            try
            {
                vocabularyParser = new VocabularyParser(stream);

            }
            catch (ArgumentNullException ex) {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new InvalidOperationException("Can not instantiate VocabularyParser(Stream stream)"));

            }

            try
            {
                vocabularyParser.Parse();

            }
            catch (Exception ex) {
                throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new Exception("Can not parse document: " + path));
            }

            stream.Close();
            return vocabularyParser;
        }