private void updateTransporterFormulaFromCache(ITransportBuilder transportBuilder, IFormulaCache formulaCache) { var formula = transportBuilder.Formula; //only add transporter formula if not already defined in the cache if (formulaCache.ExistsByName(formula.Name)) { transportBuilder.Formula = formulaCache.FindByName(formula.Name); } else { formulaCache.Add(formula); } }
private IFormula insolubleDrugStartFormula(IFormulaCache formulaCache) { if (formulaCache.ExistsByName(CoreConstants.Formula.InsolubleDrugStartFormula)) { return(formulaCache.FindByName(CoreConstants.Formula.InsolubleDrugStartFormula)); } var moleculeStartFormula = _objectBaseFactory.Create <ExplicitFormula>() .WithName(CoreConstants.Formula.InsolubleDrugStartFormula) .WithDimension(_dimensionRepository.Amount) .WithFormulaString("0"); formulaCache.Add(moleculeStartFormula); return(moleculeStartFormula); }
private T checkFormulaByType <T>(IFormulaCache formulaCache, T formula, Func <T, T, bool> areEqualFormula) where T : class, IFormula { var alreadyUsedFormula = lookForSimilarFormula(formulaCache, formula, areEqualFormula); if (alreadyUsedFormula != null) { return(alreadyUsedFormula); } if (formulaCache.ExistsByName(formula.Name)) { correctName(formulaCache, formula); } checkId(formula); //Run is required here so that the next time the same formula is found, it will be replaced automatically instead of being //added again to the cache _allCommands.Add(new AddFormulaToFormulaCacheCommand(_buildingBlock, formula).Run(_context)); return(formula); }
private IFormula drugMassFormula(IFormulaCache formulaCache) { if (formulaCache.ExistsByName(Constants.Parameters.DRUG_MASS)) { return(formulaCache.FindByName(Constants.Parameters.DRUG_MASS)); } var startFormula = _objectBaseFactory.Create <ExplicitFormula>() .WithFormulaString(Constants.Parameters.DRUG_MASS) .WithDimension(_dimensionRepository.Amount) .WithName(Constants.Parameters.DRUG_MASS); var pathToDrugMass = _objectPathFactory.CreateFormulaUsablePathFrom(ObjectPath.PARENT_CONTAINER, CoreConstants.ContainerName.ProtocolSchemaItem, Constants.Parameters.DRUG_MASS) .WithAlias(Constants.Parameters.DRUG_MASS) .WithDimension(_dimensionRepository.Amount); startFormula.AddObjectPath(pathToDrugMass); formulaCache.Add(startFormula); return(startFormula); }
public IFormula ConcentrationFormulaFor(IFormulaCache formulaCache) { if (formulaCache.ExistsByName(Constants.CONCENTRATION_FORMULA)) { return(formulaCache.FindByName(Constants.CONCENTRATION_FORMULA)); } var formula = _objectBaseFactory.Create <ExplicitFormula>() .WithName(Constants.CONCENTRATION_FORMULA) .WithFormulaString("V>0 ? M/V : 0"); formula.AddObjectPath(_objectPathFactory.CreateFormulaUsablePathFrom(ObjectPath.PARENT_CONTAINER) .WithAlias("M") .WithDimension(_dimensionFactory.Dimension(Constants.Dimension.MOLAR_AMOUNT))); formula.AddObjectPath(createVolumeReferencePath(ObjectPath.PARENT_CONTAINER, ObjectPath.PARENT_CONTAINER, Constants.Parameters.VOLUME)); formulaCache.Add(formula); formula.Dimension = _dimensionFactory.Dimension(Constants.Dimension.MOLAR_CONCENTRATION); return(formula); }
private IFormula particleDrugMassFormula(IFormulaCache formulaCache) { if (formulaCache.ExistsByName(CoreConstants.Parameters.PARTICLE_BIN_DRUG_MASS)) { return(formulaCache.FindByName(CoreConstants.Parameters.PARTICLE_BIN_DRUG_MASS)); } var pathToDrugMass = _objectPathFactory.CreateFormulaUsablePathFrom(ObjectPath.PARENT_CONTAINER, CoreConstants.Parameters.PARTICLE_BIN_DRUG_MASS) .WithAlias("ParticleBinDrugMass") .WithDimension(_dimensionRepository.Amount); var startFormula = _objectBaseFactory.Create <ExplicitFormula>() .WithFormulaString(pathToDrugMass.Alias) .WithDimension(_dimensionRepository.Amount) .WithName(CoreConstants.Parameters.PARTICLE_BIN_DRUG_MASS); startFormula.AddObjectPath(pathToDrugMass); formulaCache.Add(startFormula); return(startFormula); }