コード例 #1
0
 void Main()
 {
     {
         IAtomContainer molecule = null;
         #region
         using (var stringWriter = new StringWriter())
         {
             using (var writer = new NCDKSourceCodeWriter(stringWriter))
             {
                 writer.Write(molecule);
             }
             Console.Out.Write(stringWriter.ToString());
         }
         #endregion
     }
 }
コード例 #2
0
        public void TestOutput()
        {
            StringWriter writer   = new StringWriter();
            var          molecule = builder.NewAtomContainer();
            var          atom     = builder.NewAtom("C");

            atom.MassNumber = 14;
            molecule.Atoms.Add(atom);

            var sourceWriter = new NCDKSourceCodeWriter(writer);

            sourceWriter.Write(molecule);
            sourceWriter.Close();
            string       output  = writer.ToString();
            const string newline = "\n";

            Assert.AreEqual("{" + newline +
                            "  IChemObjectBuilder builder = NCDK.Silent.ChemObjectBuilder.Instance;" + newline +
                            "  IAtomContainer mol = builder.NewAtomContainer();" + newline +
                            "  IAtom a1 = builder.NewAtom(\"C\");" + newline +
                            "  a1.FormalCharge = 0;" + newline +
                            "  mol.Atoms.Add(a1);" + newline +
                            "}" + newline, output);
        }