Exemplo n.º 1
0
        public PythonLoader(string code, string className = "PyClass")
        {
            //creating engine and stuff
            engine = Python.CreateEngine();
            scope = engine.CreateScope();

            //loading and compiling code
            source = engine.CreateScriptSourceFromString(code, Microsoft.Scripting.SourceCodeKind.Statements);
            compiled = source.Compile();
        }
Exemplo n.º 2
0
        public void CompileCodeFromClass(string code, string className)
        {
            //loading and compiling code
            Source = Engine.CreateScriptSourceFromString(code, SourceCodeKind.Statements);
            _compiled = Source.Compile();

            //now executing this code (the code should contain a class)
            _compiled.Execute(Scope);

            //now creating an object that could be used to access the stuff inside a python script
            _pythonClass = Engine.Operations.Invoke(Scope.GetVariable(className));
        }
Exemplo n.º 3
0
 public pyDissector(string fileName)
 {
     engine = Python.CreateEngine();
     scope = engine.CreateScope();
     var runtime = engine.Runtime;
     runtime.LoadAssembly(typeof(PacketDotNet.Packet).Assembly);
     runtime.LoadAssembly(typeof(pyDissector).Assembly);
     src = engine.CreateScriptSourceFromFile(fileName);
     program = src.Compile();
     var result = program.Execute(scope);
     var filterString = scope.GetVariable<string>("nativeFilterString");
     myFilter = filterGen.genFilter(filterString);
     parseFunc = scope.GetVariable<Func<Packet, HLPacket>>("parsePacket");
 }
Exemplo n.º 4
0
 public void LoadCode(string code)
 {
     Source = Engine.CreateScriptSourceFromString(code, SourceCodeKind.Statements);
     Source.Compile();
 }