private IncludeScript ( string relativeSourcePath, System.ScriptInfo script ) : object | ||
relativeSourcePath | string |
/// Path to the target script source file relative to the application source root
/// (see |
script | System.ScriptInfo |
/// Script type (i.e. type called |
return | object |
internal object IncludeScript(string/*!*/ relativeSourcePath, ScriptInfo/*!*/ script)
{
//if (type == null)
// throw new ArgumentNullException("type");
if (relativeSourcePath == null)
throw new ArgumentNullException("relativeSourcePath");
if (script == null)
throw new ArgumentException("script");
FullPath source_root = Configuration.Application.Compiler.SourceRoot;
PhpSourceFile source_file = new PhpSourceFile(
new FullPath(source_root),
new FullPath(Path.Combine(source_root, relativeSourcePath)));
// the first script becomes the main one:
if (MainScriptFile == null)
DefineMainScript(script, source_file);
return GuardedCall((ScriptInfo scriptInfo) =>
{
//return PhpScript.InvokeMainHelper(
// (Type)scriptType,
return scriptInfo.Main(
this,
null, // no local variables
null, // no object context
null, // no class context
true);
}, script, true);
}
/// <summary> /// Performs PHP inclusion on a specified script. Equivalent to <see cref="PHP.Core.ScriptContext.IncludeScript"/>. /// </summary> /// <param name="relativeSourcePath"> /// Path to the target script source file relative to the web application root. /// </param> /// <param name="script"> /// Script info (i.e. type called <c>Default</c> representing the target script) or any type from /// the assembly where the target script is contained. In the latter case, the script type is searched in the /// assembly using value of <paramref name="relativeSourcePath"/>. /// </param> /// <returns>The value returned by the global code of the target script.</returns> /// <exception cref="InvalidOperationException">Request context has been disposed.</exception> /// <exception cref="ArgumentNullException"><paramref name="relativeSourcePath"/> or <paramref name="script"/> are <B>null</B> references.</exception> /// <exception cref="ArgumentException">Script type cannot be resolved.</exception> /// <exception cref="InvalidScriptAssemblyException">The target assembly is not a valid Phalanger compiled assembly.</exception> public object IncludeScript(string /*!*/ relativeSourcePath, ScriptInfo /*!*/ script) { if (disposed) { throw new InvalidOperationException(CoreResources.GetString("instance_disposed")); } return(scriptContext.IncludeScript(relativeSourcePath, script)); }