/// <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) { EnsureUtil.EnsureNotEmpty(typeof(NotValidException), "Script language", language); EnsureUtil.EnsureAtLeastOneNotNull(typeof(NotValidException), "No script source or resource was given", source, resource); if (!ReferenceEquals(resource, null) && resource.Length > 0) { return(GetScriptFromResource(language, resource, expressionManager, scriptFactory)); } return(GetScriptFormSource(language, source, expressionManager, scriptFactory)); }