Microsoft.Scripting.Hosting.ScriptRuntime.CreateScope C# (CSharp) Méthode

CreateScope() public méthode

public CreateScope ( ) : ScriptScope
Résultat ScriptScope
        public ScriptScope CreateScope() {
            return InvariantEngine.CreateScope();
        }

Same methods

ScriptRuntime::CreateScope ( object>.IDictionary dictionary ) : ScriptScope
ScriptRuntime::CreateScope ( IDynamicMetaObjectProvider storage ) : ScriptScope
ScriptRuntime::CreateScope ( string languageId ) : ScriptScope
ScriptRuntime::CreateScope ( string languageId, object>.IDictionary storage ) : ScriptScope
ScriptRuntime::CreateScope ( string languageId, IDynamicMetaObjectProvider storage ) : ScriptScope

Usage Example

Exemple #1
0
    static void Main(string[] args)
    {
        // set path for dynamic assembly loading
        AppDomain.CurrentDomain.AssemblyResolve +=
            new ResolveEventHandler(ResolveAssembly);

        string path = System.IO.Path.Combine(exe_path, py_path);
        pyscript = System.IO.Path.Combine(path, pyscript);
        pyscript = System.IO.Path.GetFullPath(pyscript); // normalize

        // get runtime
        ScriptRuntimeSetup scriptRuntimeSetup = new ScriptRuntimeSetup();

        LanguageSetup language = Python.CreateLanguageSetup(null);
        language.Options["Debug"] = true;
        scriptRuntimeSetup.LanguageSetups.Add(language);

        ScriptRuntime runtime = new Microsoft.Scripting.Hosting.ScriptRuntime(scriptRuntimeSetup);

        // set sys.argv
        SetPyEnv(runtime, pyscript, args);

        // get engine
        ScriptScope scope = runtime.CreateScope();
        ScriptEngine engine = runtime.GetEngine("python");

        ScriptSource source = engine.CreateScriptSourceFromFile(pyscript);
        source.Compile();

        try {
            source.Execute(scope);
        } catch (IronPython.Runtime.Exceptions.SystemExitException e) {
            Console.WriteLine(e.StackTrace);
        }
    }
All Usage Examples Of Microsoft.Scripting.Hosting.ScriptRuntime::CreateScope