Exemple #1
0
        private void moveMoleculeCalculationMethod(ModelProperties modelProperties, CompoundProperties compoundProperties, string category)
        {
            var cm = modelProperties.CalculationMethodFor(category);

            if (cm == null)
            {
                return;
            }
            modelProperties.RemoveCalculationMethod(cm);
            compoundProperties.AddCalculationMethod(cm);
        }
Exemple #2
0
        public ModelProperties Update(ModelProperties oldModelProperties, ModelProperties newModelProperties, OriginData originData)
        {
            if (oldModelProperties == null)
            {
                UpdateCategoriesIn(newModelProperties, originData);
                return(newModelProperties);
            }

            var oldModelConfig = oldModelProperties.ModelConfiguration;
            var newModelConfig = newModelProperties.ModelConfiguration;

            //same species and same model=>we can return the old one
            if (areCompatible(oldModelConfig, newModelConfig))
            {
                UpdateCategoriesIn(oldModelProperties, originData);
                return(oldModelProperties);
            }

            //in that case. Try to update as much CM as we can
            foreach (var calculationMethod in newModelProperties.AllCalculationMethods().ToList())
            {
                string category             = calculationMethod.Category;
                var    oldCalculationMethod = oldModelProperties.CalculationMethodFor(category);
                var    newCategory          = newModelConfig.CalculationMethodCategories.FindByName(category);

                if (oldCalculationMethod == null || !newCategory.AllItems().Contains(oldCalculationMethod))
                {
                    continue;
                }

                newModelProperties.RemoveCalculationMethod(calculationMethod);
                newModelProperties.AddCalculationMethod(oldCalculationMethod);
            }

            return(newModelProperties);
        }