Exemple #1
0
        private static StatResult RunStatFunction(
            StatFunction statFunction,
            Type[] dataTypes,
            object[] valuesX,
            object[] valuesY)
        {
            statFunction.InitializeAccumulationTypes(dataTypes);
            statFunction.StartCalculation();
            statFunction.Reset();

            try
            {
                if (statFunction.PrerequisiteFunctions != null && statFunction.PrerequisiteFunctions.Length > 0)
                {
                    StatResult[] preValues = new StatResult[statFunction.PrerequisiteFunctions.Length];

                    for (int i = 0; i < statFunction.PrerequisiteFunctions.Length; i++)
                    {
                        preValues[i] = StatFunction.RunStatFunction(statFunction.PrerequisiteFunctions[i], dataTypes, valuesX, valuesY);

                        if (preValues[i].Value is Exception)
                        {
                            throw ( Exception )preValues[i].Value;
                        }
                    }

                    statFunction.InitializePrerequisites(preValues);
                }

                if (statFunction.RequiresAccumulation)
                {
                    for (int i = 0; i < valuesX.Length; i++)
                    {
                        if (valuesY == null)
                        {
                            statFunction.Accumulate(new object[] { valuesX[i] });
                        }
                        else
                        {
                            statFunction.Accumulate(new object[] { valuesX[i], valuesY[i] });
                        }
                    }
                }

                statFunction.EndCalculation();
                return(statFunction.GetResult());
            }
            catch (Exception ex)
            {
                return(new StatResult(ex));
            }
        }
Exemple #2
0
 private static StatResult RunStatFunction(StatFunction statFunction, Type[] dataTypes, params object[] values)
 {
     return(StatFunction.RunStatFunction(statFunction, dataTypes, values, null));
 }