Beispiel #1
0
        public void DoExperiment(IExperiment experiment)
        {
            experiment.AtomicCollection.Sort(AtomicComparators.GetTypeDescendingComparer());
            experiment.Chemist = this;
            switch (experiment.Type)
            {
            case ExperimentType.Compound:
                LogEvents.ExperimentStarted(experiment);
                var atomicCollectionSize = experiment.AtomicCollection.Count;
                var result = CheckCompounds(experiment.AtomicCollection);
                if (atomicCollectionSize == experiment.AtomicCollection.Count)
                {
                    LogEvents.ExperimentFailed(experiment);
                }
                else
                {
                    LogEvents.ExperimentEnded(experiment);
                }
                break;

            case ExperimentType.Ion:
                LogEvents.ExperimentStarted(experiment);
                var ions = CheckIonCompounds(experiment.AtomicCollection);
                if (ions != null)
                {
                    LogEvents.IonsGot(ions);
                    LogEvents.ExperimentEnded(experiment);
                }
                else
                {
                    LogEvents.ExperimentFailed(experiment);
                }
                break;

            case ExperimentType.Isotope:
                LogEvents.ExperimentStarted(experiment);
                var isotopes = GetIsotopes(experiment.AtomicCollection);
                if (isotopes != null)
                {
                    LogEvents.IsotopeGot(isotopes);
                    LogEvents.ExperimentEnded(experiment);
                }
                else
                {
                    LogEvents.ExperimentFailed(experiment);
                }
                break;
            }
        }