Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: access indexer of a hosted object

$
0
0
I've run into this problem, too. I have tried to implement IList<> in the hopes that the object could then be indexed as an array in V8 script land:

e.g.

.NET
    public class NodeList : IList<Node>
    {
       ....
        public Node this[int index]
        {
            get
            {
                return item(index);
            }
            set
            {
            }
        }
       ...
    }
Script:
   document.getElementsByTagName('head')[0]
document.getElementsByTagName('head') returns a NodeList as expected but attempting to get [0] returns undefined (although .Item.get(0) works)

Is it possible to get an object to act as an array? Is IList the interface I should use? Should I make it a DynamicObject instead?

UPDATE: Neeeevermind. I realized I should have used the non-templated IList. It's late :P

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images