the example shown in limitFunction with a parameter of type date to insert the value of this parameter is the current date
Question
There limitFunction](fo_limit-function.html) (class ICSSoft.STORMNET.FunctionalLanguage.Function
) with parameter @date. How is this parameter to substitute the current date?
Response
Let limitFunction
set function with a parameter @date:
ExternalLangDef externalLangDef = ExternalLangDef.LanguageDef;
ICSSoft.STORMNET.FunctionalLanguage.Function limitFunction = externalLangDef.GetFunction(
externalLangDef.funcEQ,
new ParameterDef(Date, externalLangDef.DateTimeType, false, ""),
new DateTime(2000, 01, 01));
Read more about ExternalLangDef.
For Web
To pass parameters to a function in the class ICSSoft.STORMNET.Web.Tools.AdvLimitUtils
there is a method:
/// <summary>
/// Substitute a specific value instead of function parameters.
/// </summary>
/// <param name="function">the function that will replace the parameters.</param>
/// <param name="paramValues">the Reference values of parameters (parameter name - value).</param>
/// <returns>the Function in which all parameters replaced by the appropriate values.</returns>
public static Function SubstituteParameters(Function function, IDictionary<string, object> paramValues)
Example
limitFunction = AdvLimitUtils.SubstituteParameters(
limitFunction,
new Dictionary<string, object>() { {Date, DateTime.Now} });
For Win
For parameter substitution in the bounding function in the class ICSSoft.STORMNET.Windows.Forms.AdvansedLimitExtension
there is a method:
/// <summary>
/// Get restriction with the substituted parameter values
/// </summary>
/// <param name="advansedLimit">the constraint.</param>
/// <param name="parValues">a Dictionary with parameter values. Key - the parameter name</param>
/// <returns>the Function-restriction with the substituted values of the parameters</returns>
public static Function GetCustomizedFunctionByParameters<R, T>(this R advansedLimit, T parValues)
where T : IDictionary, IDictionary<string, object>
where R : AdvansedLimit
But for this method you need an instance of the class ICSSoft.STORMNET.Windows.Forms.AdvansedLimit
(object model limitations includes both the bounding function and parameter setting).
Example
AdvansedLimit advlimit = new AdvansedLimit {Function = limitFunction};
advlimit.Parameters = new ParameterDef[1] { (ParameterDef)advlimit.Function.Parameters[0] };
limitFunction = AdvansedLimitExtension.GetCustomizedFunctionByParameters(
advlimit,
new Dictionary<string, object>() { { Date, DateTime.Now } });