Exemplo n.º 1
0
        /// <summary>
        /// Retrieve a List of all ChemObject objects within an IChemModel.
        /// </summary>
        /// <param name="chemModel">The IChemModel object.</param>
        /// <returns>A List of all ChemObjects inside.</returns>
        public static List <IChemObject> GetAllChemObjects(IChemModel chemModel)
        {
            var list = new List <IChemObject>();
            // list.Add(chemModel); // only add ChemObjects contained within
            ICrystal crystal = chemModel.Crystal;

            if (crystal != null)
            {
                list.Add(crystal);
            }
            var moleculeSet = chemModel.MoleculeSet;

            if (moleculeSet != null)
            {
                list.Add(moleculeSet);
                var current = MoleculeSetManipulator.GetAllChemObjects(moleculeSet);
                foreach (var chemObject in current)
                {
                    if (!list.Contains(chemObject))
                    {
                        list.Add(chemObject);
                    }
                }
            }
            var reactionSet = chemModel.ReactionSet;

            if (reactionSet != null)
            {
                list.Add(reactionSet);
                var current = ReactionSetManipulator.GetAllChemObjects(reactionSet);
                foreach (var chemObject in current)
                {
                    if (!list.Contains(chemObject))
                    {
                        list.Add(chemObject);
                    }
                }
            }
            return(list);
        }
Exemplo n.º 2
0
        public void TestGetAllChemObjects_IAtomContainerSet()
        {
            var list = MoleculeSetManipulator.GetAllChemObjects(som);

            Assert.AreEqual(3, list.Count()); // only MoleculeSets and AtomContainers at the moment (see source code comment)
        }