/// <summary> /// Creates a new <seealso cref="ExecutableScript" /> from a dynamic source. 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="sourceExpression"> the expression which evaluates to the source 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 is null or empty or sourceExpression is null </exception> public static ExecutableScript GetScriptFromSourceExpression(string language, IExpression sourceExpression, ScriptFactory scriptFactory) { EnsureUtil.EnsureNotEmpty(typeof(NotValidException), "Script language", language); EnsureUtil.EnsureNotNull(typeof(NotValidException), "Script source expression", sourceExpression); return(scriptFactory.CreateScriptFromSource(language, sourceExpression)); }
/// <summary> /// Initializes the env scripts for a given language. /// </summary> /// <param name="language"> the language </param> /// <returns> the list of env scripts. Never null. </returns> protected internal virtual IList <ExecutableScript> initEnvForLanguage(string language) { IList <ExecutableScript> scripts = new List <ExecutableScript>(); foreach (IScriptEnvResolver resolver in envResolvers) { string[] resolvedScripts = resolver.Resolve(language); if (resolvedScripts != null) { foreach (string resolvedScript in resolvedScripts) { scripts.Add(scriptFactory.CreateScriptFromSource(language, resolvedScript)); } } } return(scripts); }