C# Class Rhino.Commonjs.Module.Require

Inheritance: Rhino.BaseFunction
Datei anzeigen Open project: hazzik/Rhino.Net

Public Methods

Method Description
Call ( Context cx, Scriptable scope, Scriptable thisObj, object args ) : object
Construct ( Context cx, Scriptable scope, object args ) : Scriptable
GetArity ( ) : int
GetFunctionName ( ) : string
GetLength ( ) : int
Install ( Scriptable scope ) : void

Binds this instance of require() into the specified scope under the property name "require".

Binds this instance of require() into the specified scope under the property name "require".

Require ( Context cx, Scriptable nativeScope, ModuleScriptProvider moduleScriptProvider, System.Script preExec, System.Script postExec, bool sandboxed ) : System

Creates a new instance of the require() function.

Creates a new instance of the require() function. Upon constructing it, you will either want to install it in the global (or some other) scope using Install(Rhino.Scriptable) , or alternatively, you can load the program's main module using RequireMain(Rhino.Context, string) and then act on the main module's exports.

RequireMain ( Context cx, string mainModuleId ) : Scriptable

Calling this method establishes a module as being the main module of the program to which this require() instance belongs.

Calling this method establishes a module as being the main module of the program to which this require() instance belongs. The module will be loaded as if require()'d and its "module" property will be set as the "main" property of this require() instance. You have to call this method before the module has been loaded (that is, the call to this method must be the first to require the module and thus trigger its loading). Note that the main module will execute in its own scope and not in the global scope. Since all other modules see the global scope, executing the main module in the global scope would open it for tampering by other modules.

Private Methods

Method Description
DefineReadOnlyProperty ( ScriptableObject obj, string name, object value ) : void
ExecuteModuleScript ( Context cx, string id, Scriptable exports, ModuleScript moduleScript, bool isMain ) : Scriptable
ExecuteOptionalScript ( System.Script script, Context cx, Scriptable executionScope ) : void
GetExportedModuleInterface ( Context cx, string id, Uri uri, Uri @base, bool isMain ) : Scriptable
GetModule ( Context cx, string id, Uri uri, Uri @base ) : ModuleScript

Method Details

Call() public method

public Call ( Context cx, Scriptable scope, Scriptable thisObj, object args ) : object
cx Rhino.Context
scope Scriptable
thisObj Scriptable
args object
return object

Construct() public method

public Construct ( Context cx, Scriptable scope, object args ) : Scriptable
cx Rhino.Context
scope Scriptable
args object
return Scriptable

GetArity() public method

public GetArity ( ) : int
return int

GetFunctionName() public method

public GetFunctionName ( ) : string
return string

GetLength() public method

public GetLength ( ) : int
return int

Install() public method

Binds this instance of require() into the specified scope under the property name "require".
Binds this instance of require() into the specified scope under the property name "require".
public Install ( Scriptable scope ) : void
scope Scriptable the scope where the require() function is to be installed.
return void

Require() public method

Creates a new instance of the require() function.
Creates a new instance of the require() function. Upon constructing it, you will either want to install it in the global (or some other) scope using Install(Rhino.Scriptable) , or alternatively, you can load the program's main module using RequireMain(Rhino.Context, string) and then act on the main module's exports.
public Require ( Context cx, Scriptable nativeScope, ModuleScriptProvider moduleScriptProvider, System.Script preExec, System.Script postExec, bool sandboxed ) : System
cx Rhino.Context the current context
nativeScope Scriptable /// a scope that provides the standard native JavaScript /// objects. ///
moduleScriptProvider ModuleScriptProvider a provider for module scripts
preExec System.Script /// an optional script that is executed in every module's /// scope before its module script is run. ///
postExec System.Script /// an optional script that is executed in every module's /// scope after its module script is run. ///
sandboxed bool /// if set to true, the require function will be sandboxed. /// This means that it doesn't have the "paths" property, and also that the /// modules it loads don't export the "module.uri" property. ///
return System

RequireMain() public method

Calling this method establishes a module as being the main module of the program to which this require() instance belongs.
Calling this method establishes a module as being the main module of the program to which this require() instance belongs. The module will be loaded as if require()'d and its "module" property will be set as the "main" property of this require() instance. You have to call this method before the module has been loaded (that is, the call to this method must be the first to require the module and thus trigger its loading). Note that the main module will execute in its own scope and not in the global scope. Since all other modules see the global scope, executing the main module in the global scope would open it for tampering by other modules.
/// if the main module is already loaded when /// required, or if this require() instance already has a different main /// module set. ///
public RequireMain ( Context cx, string mainModuleId ) : Scriptable
cx Rhino.Context the current context
mainModuleId string the ID of the main module
return Scriptable