/// <summary> /// Creates a new <seealso cref="ExecutableScript"/> from a source. It excepts static and dynamic sources. /// Dynamic means that the source is an expression which will be evaluated during execution. /// </summary> /// <param name="language"> the language of the script </param> /// <param name="source"> the source code of the script or an expression which evaluates to the source code </param> /// <param name="expressionManager"> the expression manager to use to generate the expressions of dynamic scripts </param> /// <param name="scriptFactory"> the script factory used to create the script </param> /// <returns> the newly created script </returns> /// <exception cref="NotValidException"> if language is null or empty or source is null </exception> public static ExecutableScript getScriptFormSource(string language, string source, ExpressionManager expressionManager, ScriptFactory scriptFactory) { ensureNotEmpty(typeof(NotValidException), "Script language", language); ensureNotNull(typeof(NotValidException), "Script source", source); if (isDynamicScriptExpression(language, source)) { Expression sourceExpression = expressionManager.createExpression(source); return(getScriptFromSourceExpression(language, sourceExpression, scriptFactory)); } else { return(getScriptFromSource(language, source, scriptFactory)); } }
/// <summary> /// Creates a new <seealso cref="ExecutableScript"/> from a source or resource. It excepts static and /// dynamic sources and resources. Dynamic means that the source or resource is an expression /// which will be evaluated during execution. /// </summary> /// <param name="language"> the language of the script </param> /// <param name="source"> the source code of the script or an expression which evaluates to the source code </param> /// <param name="resource"> the resource path of the script code or an expression which evaluates to the resource path </param> /// <param name="expressionManager"> the expression manager to use to generate the expressions of dynamic scripts </param> /// <param name="scriptFactory"> the script factory used to create the script </param> /// <returns> the newly created script </returns> /// <exception cref="NotValidException"> if language is null or empty or both of source and resource are invalid </exception> public static ExecutableScript getScript(string language, string source, string resource, ExpressionManager expressionManager, ScriptFactory scriptFactory) { ensureNotEmpty(typeof(NotValidException), "Script language", language); ensureAtLeastOneNotNull(typeof(NotValidException), "No script source or resource was given", source, resource); if (!string.ReferenceEquals(resource, null) && resource.Length > 0) { return(getScriptFromResource(language, resource, expressionManager, scriptFactory)); } else { return(getScriptFormSource(language, source, expressionManager, scriptFactory)); } }
/// <summary> /// Creates a new <seealso cref="ExecutableScript"/> from a static resource. /// </summary> /// <param name="language"> the language of the script </param> /// <param name="resource"> the resource path of the script code </param> /// <param name="scriptFactory"> the script factory used to create the script </param> /// <returns> the newly created script </returns> /// <exception cref="NotValidException"> if language or resource are null or empty </exception> public static ExecutableScript getScriptFromResource(string language, string resource, ScriptFactory scriptFactory) { ensureNotEmpty(typeof(NotValidException), "Script language", language); ensureNotEmpty(typeof(NotValidException), "Script resource", resource); return(scriptFactory.createScriptFromResource(language, resource)); }
/// <summary> /// Creates a new <seealso cref="ExecutableScript"/> from a dynamic resource. Dynamic means that the source /// is an expression which will be evaluated during execution. /// </summary> /// <param name="language"> the language of the script </param> /// <param name="resourceExpression"> the expression which evaluates to the resource path </param> /// <param name="scriptFactory"> the script factory used to create the script </param> /// <returns> the newly created script </returns> /// <exception cref="NotValidException"> if language is null or empty or resourceExpression is null </exception> public static ExecutableScript getScriptFromResourceExpression(string language, Expression resourceExpression, ScriptFactory scriptFactory) { ensureNotEmpty(typeof(NotValidException), "Script language", language); ensureNotNull(typeof(NotValidException), "Script resource expression", resourceExpression); return(scriptFactory.createScriptFromResource(language, resourceExpression)); }
public virtual void setUp() { scriptFactory = processEngineConfiguration.ScriptFactory; }