This project has moved and is read-only. For the latest updates, please go here.

i need access property of my class

Apr 16, 2014 at 7:06 AM
Edited Apr 16, 2014 at 7:29 AM
my global code
engine.SetGlobalValue("TestViewModel", new ScriptResultConstructor(engine));
engine.ExecuteFile(@"c:\test\test.js");
Console.WriteLine(engine.CallGlobalFunction("testViewModel"))
And ScriptResult class
    public class ScriptResultConstructor : ClrFunction
    {
        public ScriptResultConstructor(ScriptEngine engine)
            : base(engine.Function.InstancePrototype, "TestViewModel",
                new ScriptResultInstance(engine.Object.InstancePrototype))
        {
          
        }
        [JSConstructorFunction]
        public ScriptResultInstance Construct()
        {
            return new ScriptResultInstance(InstancePrototype);
        }
    }
    public class ScriptResultInstance : ObjectInstance
    {
        public bool Result { get; set; }
        public string Message { get; set; }

        public ScriptResultInstance(ObjectInstance prototype)
            : base(prototype)
        {
            PopulateFunctions();
        }

        public ScriptResultInstance(ObjectInstance prototype, bool result, string message)
            : base(prototype)
        {
            Result = result;
            Message = message;

        }
        [JSFunction(Name = "TestScriptResult")]
        public ScriptResultInstance TestScriptResult()
        {

            var model = new ScriptResultInstance(Engine.Object.InstancePrototype, true, "ok");
            return model;
        }



    }
And js code
function testViewModel() {
    var str = new TestViewModel();
    return str.TestScriptResult().Message;
}
i Expect str.TestScriptResult().Message Get Ok string
but get nothing
Apr 16, 2014 at 8:48 PM
Apply [JsProperty] to the properties.