// Utility ////////////////////////////////// protected virtual void bind(Parse heads) { columnBindings = new TypeAdapter[heads.size()]; for (int i = 0; heads != null; i++, heads = heads.more) { String name = heads.text(); String suffix = "()"; try { if (name == "") { columnBindings[i] = null; } else if (name.EndsWith(suffix)) { columnBindings[i] = bindMethod(name.Substring(0, name.Length - suffix.Length)); } else { columnBindings[i] = bindField(name); } } catch (Exception e) { exception(heads, e); } } }
public void testIndexing() { Parse p = new Parse("leader<table><tr><td>one</td><td>two</td><td>three</td></tr><tr><td>four</td></tr></table>trailer"); Assert.AreEqual("one", p.at(0,0,0).body); Assert.AreEqual("two", p.at(0,0,1).body); Assert.AreEqual("three", p.at(0,0,2).body); Assert.AreEqual("three", p.at(0,0,3).body); Assert.AreEqual("three", p.at(0,0,4).body); Assert.AreEqual("four", p.at(0,1,0).body); Assert.AreEqual("four", p.at(0,1,1).body); Assert.AreEqual("four", p.at(0,2,0).body); Assert.AreEqual(1, p.size()); Assert.AreEqual(2, p.parts.size()); Assert.AreEqual(3, p.parts.parts.size()); Assert.AreEqual("one", p.leaf().body); Assert.AreEqual("four", p.parts.last().leaf().body); }
public void testIndexing() { Parse p = new Parse("leader<table><tr><td>one</td><td>two</td><td>three</td></tr><tr><td>four</td></tr></table>trailer"); Assert.AreEqual("one", p.at(0, 0, 0).body); Assert.AreEqual("two", p.at(0, 0, 1).body); Assert.AreEqual("three", p.at(0, 0, 2).body); Assert.AreEqual("three", p.at(0, 0, 3).body); Assert.AreEqual("three", p.at(0, 0, 4).body); Assert.AreEqual("four", p.at(0, 1, 0).body); Assert.AreEqual("four", p.at(0, 1, 1).body); Assert.AreEqual("four", p.at(0, 2, 0).body); Assert.AreEqual(1, p.size()); Assert.AreEqual(2, p.parts.size()); Assert.AreEqual(3, p.parts.parts.size()); Assert.AreEqual("one", p.leaf().body); Assert.AreEqual("four", p.parts.last().leaf().body); }
public virtual int size() { return(more == null ? 1 : more.size() + 1); }
// Utility ////////////////////////////////// protected virtual void bind(Parse heads) { columnBindings = new TypeAdapter[heads.size()]; for (int i=0; heads!=null; i++, heads=heads.more) { String name = heads.text(); String suffix = "()"; try { if (name == "") { columnBindings[i] = null; } else if (name.EndsWith(suffix)) { columnBindings[i] = bindMethod(name.Substring(0,name.Length-suffix.Length)); } else { columnBindings[i] = bindField(name); } } catch (Exception e) { exception (heads, e); } } }