/// <summary> /// Resets the IronPython engine scope, clears any imported modules and .NET types. /// </summary> public void Reset() { ScriptScope = _scriptEngine.CreateScope(); _typeLoader.Reset(); _autocompleter.Reset(); InstanceMembers.Clear(); StaticMembers.Clear(); Instances.Clear(); Statics.Clear(); InstancesAndStaticsDirty = true; RunScript("import clr"); RunScript("from System import Array"); }
/// <summary> /// Resets the C# script context, clears any references and imports. /// </summary> public void Reset() { Globals = new ExpandoWrapper { globals = new ExpandoObject() }; ScriptOptions = ScriptOptions.Default.WithReferences("System.Dynamic", "Microsoft.CSharp"); _typeLoader.Reset(); _warmupTask = Task.Run(async() => { // Assignment and literal evaluation to warm up the scripting context. // Without warmup, there is a considerable delay on first command evaluation. _scriptState = await CSharpScript.RunAsync( code: "int quakeconsole_dummy_value = 1;", globalsType: typeof(ExpandoWrapper), globals: Globals ); }); }