/// <summary> /// Execute code within a given module context and returns the result. /// The module must be local with respect to the compiled code object. /// </summary> public object Evaluate(IScriptModule module) { ScriptModule localModule; if (module == null) { localModule = RemoteWrapper.TryGetLocal <ScriptModule>(ScriptDomainManager.CurrentManager.Host.DefaultModule); } else { localModule = RemoteWrapper.GetLocalArgument <ScriptModule>(module, "module"); } return(_code.Run(localModule)); }
/// <summary> /// Creates a module. /// <c>dictionary</c> can be <c>null</c> /// </summary> /// <returns></returns> public IScriptModule CreateModule(string name, ScriptModuleKind kind, IAttributesCollection dictionary, params ICompiledCode[] compiledCodes) { Contract.RequiresNotNullItems(compiledCodes, "compiledCodes"); ScriptCode[] script_codes = new ScriptCode[compiledCodes.Length]; for (int i = 0; i < compiledCodes.Length; i++) { script_codes[i] = ScriptCode.FromCompiledCode(RemoteWrapper.TryGetLocal <CompiledCode>(compiledCodes[i])); if (script_codes[i] == null) { throw new ArgumentException(Resources.RemoteCodeModuleComposition, String.Format("{0}[{1}]", "compiledCodes", i)); } } return(_manager.CreateModule(name, kind, new Scope(dictionary), script_codes)); }