public static void Scenario_RemoteEvaluation() { ScriptRuntime runtime = ScriptRuntime.CreateRemote( AppDomain.CreateDomain("remote domain"), ScriptRuntimeSetup.ReadConfiguration() ); ScriptEngine engine = runtime.GetEngine("python"); ObjectOperations ops = engine.Operations; ObjectHandle classC = engine.ExecuteAndWrap(@" class C(object): def __init__(self, value): self.value = value def __int__(self): return self.value C "); ObjectHandle result = ops.CreateInstance(classC, 17); int intResult = ops.Unwrap <int>(result); Console.WriteLine(intResult); }
//static string ironpath = @"InstaRogi.py"; public PythonIron() { engine = Python.CreateEngine(); source = engine.CreateScriptSourceFromFile("InstaRogi.py", Encoding.UTF8); scope = engine.CreateScope(); operations = engine.CreateOperations(); source.Execute(scope); dynamic rogi_class = scope.GetVariable("InstaRogi"); dynamic rogi_class_obj = operations.CreateInstance(rogi_class); //var f = operations.GetMember(rogi_class_obj, ""); //string tmp = f as string; //System.Diagnostics.Debug.Write("\nurl: "+ tmp +"\n"); }
internal PythonProcessor(ObjectOperations op, object processorClass) { var processor = (object)op.CreateInstance(processorClass); Process = op.GetMember <Func <TSource, TResult> >(processor, PythonHelper.ProcessFunction); if (op.ContainsMember(processor, PythonHelper.UnloadFunction)) { Unload = op.GetMember <Action>(processor, PythonHelper.UnloadFunction); } if (op.ContainsMember(processor, PythonHelper.LoadFunction)) { Load = op.GetMember <Action>(processor, PythonHelper.LoadFunction); } }