Coder Social home page Coder Social logo

Comments (5)

sergioamm17 avatar sergioamm17 commented on June 9, 2024 1

Yes, my class MyCustomObject already has a parameterless constructor.

I made a couple of more tests and it looks the type of the property Origin is not registered at all. This should be why I can not assign a new object to the property, even if I create another object type, it's not the same as the property and that throws the exception.

So far, I need to fix a namespaces error, to register succesfully the Origin Type.

This is a shared project between a big team, that's why I'm trying to fix this kind of programming errors.
Thanks for your help, you made me understand the issue.

from clearscript.

ClearScriptLib avatar ClearScriptLib commented on June 9, 2024 1

Please reopen this issue if you have additional questions or comments about this topic. Thank you!

from clearscript.

ClearScriptLib avatar ClearScriptLib commented on June 9, 2024

Hi @sergioamm17,

We're assuming that IM is a host object. If that's correct, how are the Reference and Origin properties defined in managed code?

Also, what is Namespace.MyObject? If that's a host object or type, how are you exposing it to the script engine?

Thanks!

from clearscript.

sergioamm17 avatar sergioamm17 commented on June 9, 2024

Yes, the IM is a host object.

This is the Origin property
private MyCustomObject _origin; public MyCustomObject Origin { get { return _origin; } set { _origin = value; } }
And the Reference property
public string Reference { get { return Convert.ToString(Entity.iProperties[MemberName.Reference]); } set { Entity.iProperties[MemberName.Reference] = value; } }

Reference is working as expected, however, the Origin is not working at all. I think the reason is because is an complex type (my custom object)

Namespace.MyObject is the namespace and name of my custom class, for example MyCustomObject according to the shared example. I already registered my custom type using Engine.AddHostType("MyTypes", typeof(Namespace.MyCustomObject));
I want to set the new value for the Origin property from the script.

from clearscript.

ClearScriptLib avatar ClearScriptLib commented on June 9, 2024

Hello @sergioamm17,

I already registered my custom type using Engine.AddHostType("MyTypes", typeof(Namespace.MyCustomObject));
I want to set the new value for the Origin property from the script.

Given that AddHostType call, the JavaScript expression new MyTypes() should create a MyCustomObject instance (assuming that MyCustomObject has a parameterless constructor).

Can you verify that?

from clearscript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.