Esempio n. 1
0
        private IFormula createFormula(RateKey rateKey)
        {
            if (rateKey.IsBlackBoxFormula)
            {
                return(_objectBaseFactory.Create <BlackBoxFormula>()
                       .WithId(rateKey)
                       .WithName(rateKey.Rate));
            }

            if (rateKey.IsTableWithOffsetFormula)
            {
                return(createTableFormulaWithOffset(rateKey));
            }

            if (rateKey.IsTableWithXArgumentFormula)
            {
                return(createTableFormulaWithArgument(rateKey));
            }

            //now it can be either dynamic formula or explicit formula
            FormulaWithFormulaString formula;

            if (rateKey.IsDynamicSumFormula)
            {
                var sumFormula = _objectBaseFactory.Create <SumFormula>();
                sumFormula.Criteria = _dynamicFormulaCriteriaRepository.CriteriaFor(rateKey).Clone();
                formula             = sumFormula;
            }
            else
            {
                formula = _objectBaseFactory.Create <ExplicitFormula>();
            }

            formula.WithFormulaString(_rateFormulaRepository.FormulaFor(rateKey))
            .WithId(rateKey)
            .WithName(rateKey.Rate);

            foreach (var rateObjectPath in _rateObjectPathsRepository.ObjectPathsFor(rateKey))
            {
                formula.AddObjectPath(rateObjectPath.Clone <IFormulaUsablePath>());
            }

            addTimeReferenceIfNeeded(formula);

            //set formula dimension if available
            var dimensionName = _rateFormulaRepository.DimensionNameFor(rateKey);
            var dimension     = _dimensionRepository.DimensionByName(dimensionName);

            formula.Dimension = dimension;

            if (formula.ObjectPaths.Any() || formula.IsAnImplementationOf <DynamicFormula>())
            {
                return(formula);
            }

            //this is actually a constant formula! Evaluate the function and return a contant formula
            return(constantFormula(formula.Calculate(null)).WithDimension(dimension));
        }
        private void checkRate(IRateObjectPathsRepository rateObjectPathsRepo, string rate)
        {
            const string calcMethod = "EndosomalSpaceBindingFormulas";

            var objectPaths    = rateObjectPathsRepo.ObjectPathsFor(new RateKey(calcMethod, rate));
            var kassObjectPath = objectPaths.First(p => p.Alias.Equals("kass_FcRn"));

            kassObjectPath.PathAsString.EndsWith("kass (FcRn)").ShouldBeTrue();
        }