This project has moved. For the latest updates, please go here.

Handle access to element by index

Aug 13, 2014 at 4:31 PM
Hello.
I am trying to create a simple object-wrapper for html DOM and pass it to Script Engine as a global value.
I have one issue which I can't solve.
There is explanation of my issue with example:
var eng = new ScriptEngine();
HtmlDom html = new HtmlDom(doc);
eng.SetGlobalValue("document", html); 
eng.Execute(js);
my js file contains line
document.forms[0].elements[1].value.
HtmlDom class has property forms of DomElementsType.
DomElementsType is derived from DynamicObject.
I expected to override TryGetIndex in DomElementsType and implement logic here to return element which I need, but this function doesn't get call.
Also I tried to create indexer function
public DomElementsType this[int index]
        {
            get
            {
                 /*  
there is logic to return certain element
                */
            }

        }
Result the same.
I can't just use array, because form object should support Submit function for example.

How I can accomplish my goal?
Aug 14, 2014 at 12:48 PM
Issue solved.
I just inherited objects which I pass to Script engine from ObjectInstance or ArrayInstance and overrode method GetMissingPropertyValue
Marked as answer by Gdocal on 8/14/2014 at 5:48 AM