public IDictionary <string, IScriptModule> GetPublishedModules()
        {
            IDictionary <string, IScriptModule> result = _manager.Environment.GetPublishedModules();

            string[] keys = new string[result.Count];
            result.Keys.CopyTo(keys, 0);

            foreach (string key in keys)
            {
                result[key] = RemoteWrapper.WrapRemotable <IScriptModule>(result[key]);
            }

            return(result);
        }
Esempio n. 2
0
        /// <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));
        }
Esempio n. 3
0
        /// <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));
        }
 public ICompiledCode CompileFileContent(string path, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileFileContent(path, module)));
 }
 public ICompiledCode CompileFileContent(string path)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileFileContent(path)));
 }
 public IScriptModule CompileFile(string path, string moduleName)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_engine.CompileFile(path, moduleName)));
 }
 public ICompiledCode CompileInteractiveCode(string code)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileInteractiveCode(code)));
 }
Esempio n. 8
0
 public virtual SourceUnit TryGetSourceFileUnit(IScriptEngine engine, string path, Encoding encoding)
 {
     Debug.Assert(_remoteHost != null);
     return(_remoteHost.TryGetSourceFileUnit(RemoteWrapper.WrapRemotable <IScriptEngine>(engine), path, encoding));
 }
 public ICompiledCode CompileSourceUnit(SourceUnit sourceUnit, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileSourceUnit(sourceUnit, module)));
 }
 public ICompiledCode CompileStatements(string statement, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileStatements(statement, module)));
 }
 public IScriptModule CompileModule(string name, params SourceUnit[] sourceUnits)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_manager.Environment.CompileModule(name, sourceUnits)));
 }
 public IScriptModule CreateModule(string name, ScriptModuleKind kind, IAttributesCollection dictionary, params ICompiledCode[] compiledCodes)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_manager.Environment.CreateModule(name, kind, dictionary, compiledCodes)));
 }
 public IScriptModule CreateModule(string name, params ICompiledCode[] compiledCodes)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_manager.Environment.CreateModule(name, compiledCodes)));
 }
Esempio n. 14
0
 // Gets a LanguageContext for the specified module that captures the current state
 // of the module which will be used for compilation and execution of the next piece of code against the module.
 private CodeContext GetCodeContext(IScriptModule module)
 {
     return(GetCodeContext(RemoteWrapper.GetLocalArgument <ScriptModule>(module ??
                                                                         ScriptDomainManager.CurrentManager.Host.DefaultModule, "module")));
 }
Esempio n. 15
0
 // throws SerializationException
 public virtual bool TryGetVariable(IScriptEngine engine, SymbolId name, out object value)
 {
     Debug.Assert(_remoteHost != null);
     return(_remoteHost.TryGetVariable(RemoteWrapper.WrapRemotable <IScriptEngine>(engine), name, out value));
 }
Esempio n. 16
0
 public virtual void ModuleCreated(IScriptModule module)
 {
     Contract.RequiresNotNull(module, "module");
     Debug.Assert(_remoteHost != null);
     _remoteHost.ModuleCreated(RemoteWrapper.WrapRemotable <IScriptModule>(module));
 }
Esempio n. 17
0
 /// <summary>
 /// TODO: Called under a lock. Should work with the engine via the argument only.
 /// </summary>
 public virtual void EngineCreated(IScriptEngine engine)
 {
     Contract.RequiresNotNull(engine, "engine");
     Debug.Assert(_remoteHost != null);
     _remoteHost.EngineCreated(RemoteWrapper.WrapRemotable <IScriptEngine>(engine));
 }
 public ICompiledCode CompileCode(string code, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileCode(code, module)));
 }
 public ICompiledCode CompileExpression(string expression, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileExpression(expression, module)));
 }
 public IScriptModule CompileModule(string name, ScriptModuleKind kind, CompilerOptions options, ErrorSink errorSink, IAttributesCollection dictionary, params SourceUnit[] sourceUnits)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_manager.Environment.CompileModule(name, kind, options, errorSink, dictionary, sourceUnits)));
 }
 public ICompiledCode CompileCodeDom(System.CodeDom.CodeMemberMethod code, IScriptModule module)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileCodeDom(code, module)));
 }
 public IScriptModule MakeModule(string name)
 {
     return(RemoteWrapper.WrapRemotable <IScriptModule>(_compiledCode.MakeModule(name)));
 }
 public ICompiledCode CompileSourceUnit(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink)
 {
     return(RemoteWrapper.WrapRemotable <ICompiledCode>(_engine.CompileSourceUnit(sourceUnit, options, errorSink)));
 }
Esempio n. 24
0
 public void PublishModule(IScriptModule module, string publicName)
 {
     _manager.PublishModule(RemoteWrapper.GetLocalArgument <ScriptModule>(module, "module"), publicName);
 }