Skip to content
This repository has been archived by the owner on Mar 1, 2019. It is now read-only.

O.Prop1.Prop2 fails #6

Closed
liviuu opened this issue Mar 25, 2013 · 2 comments
Closed

O.Prop1.Prop2 fails #6

liviuu opened this issue Mar 25, 2013 · 2 comments

Comments

@liviuu
Copy link

liviuu commented Mar 25, 2013

when O is exposed, Prop1 of type T2 is exposed and T2.Prop2 is exposed including types,

still O.Prop1.Prop2 fails with undefined error...

@liviuu
Copy link
Author

liviuu commented Mar 25, 2013

public class Cls
        {
            private string prop = "property: Prop";
            private InnerCls inner = new InnerCls();

            public string Prop
            {
                get { return prop; }
                set { prop = value; }
            }

            public InnerCls Inner
            {
                get { return inner; }
                set { inner = value; }
            }
        }

        public class InnerCls
        {
            private string a = "A";

            public string A
            {
                get { return a; }
                set { a = value; }
            }
        }


        [Test]
        public void TestInnerProp()
        {
            var engine = new ScriptEngine();
            engine.EnableDebugging = true;
            engine.ForceStrictMode = true;

            JurassicExposer.RegisterInfos(typeof(InnerCls), new JurassicInfo("A", new JSPropertyAttribute()));
            JurassicExposer.ExposeClass(typeof(InnerCls), engine);

            JurassicExposer.RegisterInfos(typeof(Cls), new JurassicInfo("Prop", new JSPropertyAttribute()));
            JurassicExposer.RegisterInfos(typeof(Cls), new JurassicInfo("Inner", new JSPropertyAttribute()));
            JurassicExposer.ExposeClass(typeof(Cls), engine);


            JurassicExposer.ExposeInstance(engine, new Cls(), "c");
            JurassicExposer.ExposeFunction(engine, new Action<string>(Console.WriteLine), "log");

            engine.Execute("log(\"Hello, \" + c.Inner.A + \"!\");");

        }

@frozenice
Copy link
Owner

Hi,

I finally got some time to look at this. It's a limitation of how RegisterInfos currently works: It will just register the infos from the first call and ignore any subsequent calls for the same type (I created issue #7 about this).

Your code runs when it's changed like this:

JurassicExposer.RegisterInfos(typeof(Cls),
  new JurassicInfo("Prop", new JSPropertyAttribute()),
  new JurassicInfo("Inner", new JSPropertyAttribute())
);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants