protected override void Context()
        {
            base.Context();
            _formulaCache                = new FormulaCache();
            _compoundFactory             = IoC.Resolve <ICompoundFactory>();
            _parameterAlternativeFactory = IoC.Resolve <IParameterAlternativeFactory>();
            _compound = _compoundFactory.Create().WithName("Comp");
            _compound.Parameter(Constants.Parameters.MOL_WEIGHT).Value = 250;
            //Two simple parameters without alternatives

            //one parameter defined as a constant for which an alternative was also specififed
            var lipoGroup = _compound.ParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_LIPOPHILICITY);

            _alternativeLipo1 = _parameterAlternativeFactory.CreateAlternativeFor(lipoGroup).WithName("ALT_LIPO1").WithId("ALT_LIPO1");
            _alternativeLipo1.Parameter(CoreConstants.Parameters.LIPOPHILICITY).Value = 2;
            _alternativeLipo2 = _parameterAlternativeFactory.CreateAlternativeFor(lipoGroup).WithName("ALT_LIPO2").WithId("ALT_LIPO2");
            _alternativeLipo2.Parameter(CoreConstants.Parameters.LIPOPHILICITY).Value = 5;
            lipoGroup.AddAlternative(_alternativeLipo1);
            lipoGroup.AddAlternative(_alternativeLipo2);

            //one parameter defined as a formula with a default calculated alternative

            var permAlternativeGroup = _compound.ParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_PERMEABILITY);

            //value cannot be changed by user
            _alternativePerm1 = _parameterAlternativeFactory.CreateDefaultAlternativeFor(permAlternativeGroup).WithName("ALT_PERM1").WithId("ALT_PERM1");
            _alternativePerm2 = _parameterAlternativeFactory.CreateAlternativeFor(permAlternativeGroup).WithName("ALT_PERM2").WithId("ALT_PERM2");
            _alternativePerm2.Parameter(CoreConstants.Parameters.PERMEABILITY).Value = 10;
            permAlternativeGroup.AddAlternative(_alternativePerm1);
            permAlternativeGroup.AddAlternative(_alternativePerm2);
        }
Exemple #2
0
        private void readCompoundFromTemplate(Compound compound)
        {
            //STEP1: Add all parameters defined for the compound from the database
            _parameterContainerTask.AddCompoundParametersTo(compound);

            foreach (var group in _parameterGroupTask.GroupsUsedBy(compound.AllParameters().ToList()).Where(groupNeedsAlterntive))
            {
                // create and add new compound parameter group
                var compoundParamGroup = _objectBaseFactory.Create <ParameterAlternativeGroup>().WithName(group.Name);
                compound.AddParameterAlternativeGroup(compoundParamGroup);

                // create a default alternative
                compoundParamGroup.AddAlternative(_parameterAlternativeFactory.CreateDefaultAlternativeFor(compoundParamGroup));
            }
        }