I'm embedding IronPython into C# as a way to modify the program I am working on. As such, there are multiple files which need to be used at once.
Code = "";
Engine = Python.CreateEngine();
Runtime = Engine.Runtime;
var files = Directory.GetFiles("script", "*.py", SearchOption.AllDirectories);
foreach (var tr in files.Select(file => new StreamReader(file)))
{
Code += "\n";
Code += tr.ReadToEnd();
tr.Close();
}
Scope = Engine.CreateScope();
Engine.CreateScriptSourceFromString(AddImports(Code)).Execute(Scope);
This takes all the files in /script and combines them into a single string to have a script source created from them, this is, of course, a flawed method because if the classes do not inherit in an alphabetical order, an UnboundNameException will occur
class bar(foo):
pass
class foo():
pass
How would I go about compiling all of the files in a normal manner?