.net - Creating Instances of IronPython Classes From C# -


I want to create an example of an IronPython class from C #, but failed in my current efforts.

This is my current code:

  ConstructorInfo [] ci = type.GetConstructors (); Foreach (C from T, constructor Info T, where T. Gate parameter (.) Select length == 1) Python type pettype = dynamic hanger.gatepathon typeformat type (type); Object [] consparams = new object [1]; Consparams [0] = pipe; _biegex [type] = t. Invoke (Compass); Pytype .__ init __ (_ objects [type]); break; }  

I created the example of the object t. I'm able to call invoice (compromara), but the __ init __ method is not being asked, and so all the properties that are set up with my Python script do not use it . Even with the clear pytype.__init __ call, the construction object still does not seem to be initial.

Using ScriptEngine.Operations.CreateInstance,

I am using IronPython 2.6 with .NET 4.0 as .NET 4.0.

Edit : Little explanation on how I intend to do this:

In C #, I have a class: Public static object institute (type type) {// immediately here}}

In Python, the following code:

  class MyClass (object): def __init __ (self): Print "This" should be called "Foo.Instantiate (MyClass)  

__ Init __ method never seems called

  Fixed zero main (string [ ] Args) {const string script = @ "class A (object): def __init __ (self): self. A = 100 square B (object): def __init __ (self, A, V): self A = A self. V = v df run (self): returns self AA + Self. V "; Var engine = Python. Creteyncin (); var scope = engine.CreateScope (); Engine.Execute (scripts, scope); Var type A = scope.Get variable (" A "); var typeb = scope. Variable ("B"); Var a = engine.Operations.CreateInstance (typeA); Var B = Engine. Operation Crete Instance (Type B, A, 20); Console.WriteLine (b.run ()); // 120}  

edited as explained in the query

  class event {static zero main (string [] Args) {Var Engines = Python Crete Gen (); Var scriptScope = engine.CreateScope (); var foo = new foo (engine); scriptScope .set variable ("foo", foo); const string script = @ "class myclass (object): def __init __ ( Self): "print" should be called "fu. Create (myclass)"; Var v = engine.Execute (script, scriptScope); }} Public class fu {private readonly scale engine engine; Public Fu (script engine engine) {this.engine = engine; } Create Public Object (Object T) {Return engine. operation. Create Instances (T); }}  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -