Example #1
0
 public override T Read <T>(T obj)
 {
     if (obj is IAtomContainer)
     {
         try
         {
             parserHelper = new PubChemXMLHelper(obj.Builder);
             builder      = obj.Builder;
             return((T)ReadMolecule());
         }
         catch (IOException e)
         {
             throw new CDKException("An IO Exception occurred while reading the file.", e);
         }
         catch (CDKException)
         {
             throw;
         }
         catch (Exception e)
         {
             throw new CDKException("An error occurred: " + e.Message, e);
         }
     }
     else
     {
         throw new CDKException("Only supported is reading of IAtomContainer objects.");
     }
 }
Example #2
0
        /// <summary>
        /// Constructs a new EnumerablePCSubstancesXMLReader that can read
        /// </summary>
        /// <param name="input">The input stream</param>
        /// <param name="builder">The builder</param>
        /// <exception cref="IOException">if there is error in getting the <see cref="NCDK.Config.IsotopeFactory"/></exception>
        /// <event cref="Exception">if there is an error in setting up the XML parser</event>
        public EnumerablePCSubstancesXMLReader(TextReader input, IChemObjectBuilder builder)
        {
            parserHelper = new PubChemXMLHelper(builder);

            primarySource = input;
            try
            {
                parser = XDocument.Load(primarySource).Root;
            }
            catch (Exception e)
            {
                throw new CDKException("Error while opening the input:" + e.Message, e);
            }
        }