/// <summary> /// Set the parameter index on the CodeExpression using /// EvaluationData. /// </summary> /// <param name="toSet">CodeExpression on which to set the /// parameter index.</param> /// <param name="parameterIndex">Index to set.</param> public static void SetParameterIndex(CodeObject toSet, int parameterIndex) { EvaluationData data = toSet.UserData[typeof(EvaluationData)] as EvaluationData; if (data == null) { data = new EvaluationData(); toSet.UserData.Add(typeof(EvaluationData), data); } data.ParameterIndex = parameterIndex; }
/// <summary> /// Helper method used for setting the type of /// a CodeExpression through use of EvaluationData. /// </summary> /// <param name="toSet">CodeExpression to adorn with /// type information.</param> /// <param name="newType">Type of the CodeExpression's result.</param> public static void SetType(CodeObject toSet, Type newType) { EvaluationData data = toSet.UserData[typeof(EvaluationData)] as EvaluationData; if (data == null) { data = new EvaluationData(); toSet.UserData.Add(typeof(EvaluationData), data); } data.Type = newType; }
/// <summary> /// Get the CodeExpression object's corresponding index /// into the IExpressionEvaluator's parameter list using /// EvaluationData. /// </summary> /// <param name="toGet">Expression for which to get the /// parameter.</param> /// <param name="throwIfNotExist">Whether to throw an /// exception if the parameter cannot be found. True to /// throw.</param> /// <returns>The index into the parameter list for this /// expression's replacement value.</returns> public static int GetParameterIndex(CodeObject toGet, bool throwIfNotExist) { EvaluationData data = toGet.UserData[typeof(EvaluationData)] as EvaluationData; if (data == null) { if (throwIfNotExist) { throw new ApplicationException("No EvaluationData from which to extract the parameter."); } return(-1); } else { return(data.ParameterIndex); } }
/// <summary> /// Helper method used for getting the type of /// a CodeExpression through use of EvaluationData. /// </summary> /// <param name="toGet">CodeExpression which is adorned /// with type information.</param> /// <param name="throwIfNotExist">Whether to throw an /// exception if the type data is not available. True to /// throw.</param> /// <returns>The type of the result of the CodeExpression.</returns> public static Type GetType(CodeObject toGet, bool throwIfNotExist) { EvaluationData data = toGet.UserData[typeof(EvaluationData)] as EvaluationData; if (data == null) { if (throwIfNotExist) { throw new ApplicationException("The expression did not contain an EvaluationData object."); } return(null); } else { return(data.Type); } }
/// <summary> /// Set the parameter index on the CodeExpression using /// EvaluationData. /// </summary> /// <param name="toSet">CodeExpression on which to set the /// parameter index.</param> /// <param name="parameterIndex">Index to set.</param> public static void SetParameterIndex(CodeObject toSet, int parameterIndex) { EvaluationData data = toSet.UserData[typeof(EvaluationData)] as EvaluationData; if (data == null) { data = new EvaluationData(); toSet.UserData.Add(typeof(EvaluationData), data); } data.ParameterIndex = parameterIndex; }
/// <summary> /// Helper method used for setting the type of /// a CodeExpression through use of EvaluationData. /// </summary> /// <param name="toSet">CodeExpression to adorn with /// type information.</param> /// <param name="newType">Type of the CodeExpression's result.</param> public static void SetType(CodeObject toSet, Type newType) { EvaluationData data = toSet.UserData[typeof(EvaluationData)] as EvaluationData; if (data == null) { data = new EvaluationData(); toSet.UserData.Add(typeof(EvaluationData), data); } data.Type = newType; }