PHP.Core.ScriptContext.IncludeScript C# (CSharp) Method

IncludeScript() private method

Performs PHP inclusion on a specified script.

The inclusion inheres in adding the target to the list of included scripts on the current script context (see ScriptContext.Scripts and in a call to the global code of the target script.

Request context has been disposed. or are null references. Script type cannot be resolved. The target assembly is not a valid Phalanger compiled assembly.
private IncludeScript ( string relativeSourcePath, System.ScriptInfo script ) : object
relativeSourcePath string /// Path to the target script source file relative to the application source root /// (see Configuration.Application.Compiler.SourceRoot. ///
script System.ScriptInfo /// Script type (i.e. type called Default representing the target script) or any type from /// the assembly where the target script is contained (useful for multi-script assemblies, where script types are /// not directly available from C# as they have mangled names). In the latter case, the script type is searched in the /// assembly using value of . ///
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);
		}

Usage Example

Beispiel #1
0
        /// <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));
        }