Rhino.Commonjs.Module.ModuleScript.GetBase C# (CSharp) Method

GetBase() public method

Returns the base URI from which this module source was loaded, or null if it was loaded from an absolute URI.
Returns the base URI from which this module source was loaded, or null if it was loaded from an absolute URI.
public GetBase ( ) : Uri
return System.Uri
		public virtual Uri GetBase()
		{
			return @base;
		}

Usage Example

Exemplo n.º 1
0
		private Scriptable ExecuteModuleScript(Context cx, string id, Scriptable exports, ModuleScript moduleScript, bool isMain)
		{
			ScriptableObject moduleObject = (ScriptableObject)cx.NewObject(nativeScope);
			Uri uri = moduleScript.GetUri();
			Uri @base = moduleScript.GetBase();
			DefineReadOnlyProperty(moduleObject, "id", id);
			if (!sandboxed)
			{
				DefineReadOnlyProperty(moduleObject, "uri", uri.ToString());
			}
			Scriptable executionScope = new ModuleScope(nativeScope, uri, @base);
			// Set this so it can access the global JS environment objects.
			// This means we're currently using the "MGN" approach (ModuleScript
			// with Global Natives) as specified here:
			// <http://wiki.commonjs.org/wiki/Modules/ProposalForNativeExtension>
			executionScope.Put("exports", executionScope, exports);
			executionScope.Put("module", executionScope, moduleObject);
			moduleObject.Put("exports", moduleObject, exports);
			Install(executionScope);
			if (isMain)
			{
				DefineReadOnlyProperty(this, "main", moduleObject);
			}
			ExecuteOptionalScript(preExec, cx, executionScope);
			moduleScript.GetScript().Exec(cx, executionScope);
			ExecuteOptionalScript(postExec, cx, executionScope);
			return ScriptRuntime.ToObject(nativeScope, ScriptableObject.GetProperty(moduleObject, "exports"));
		}