コード例 #1
0
        /// <summary>
        /// Verify a collection of variables to ensure that all the variable names are valid.
        /// Users are not allowed to overwrite reserved variables or use function names as variables.
        /// If an invalid variable is detected an exception is thrown.
        /// </summary>
        /// <param name="variables">The colletion of variables that must be verified.</param>
        private void VerifyVariableNames(Dictionary <string, double> variables)
        {
            foreach (string variableName in variables.Keys)
            {
                if (EngineUtil.IsReservedVariable(variableName))
                {
                    throw new ArgumentException(string.Format("The name \"{0}\" is a reservered variable name that cannot be overwritten.", variableName), "variables");
                }

                if (FunctionRegistry.IsFunctionName(variableName))
                {
                    throw new ArgumentException(string.Format("The name \"{0}\" is a function name. Parameters cannot have this name.", variableName), "variables");
                }
            }
        }