Exemplo n.º 1
0
        public ElementToken(int index, RangeList rangeList)
            : base(rangeList)
        {
            _startIndex = index;
            _rangeList = rangeList;

            Tokens = new LinkedList<ParseToken>();
            Attributes = new Dictionary<string, string>();
        }
Exemplo n.º 2
0
 static ParseToken Create(XNode node, int index, RangeList list)
 {
     if (node is XText)
     {
         var len = ((XText)node).Value.Length;
         return new TextToken(index, len, list);
     }
     if (node is XElement)
     {
         var el = (XElement)node;
         var en = new ElementToken(index, list);
         ParseElement(en, el, index, list);
         return en;
     }
     throw new NotSupportedException(node.NodeType.ToString());
 }
Exemplo n.º 3
0
        static void ParseElement(ElementToken en, XElement el, int index, RangeList list)
        {
            // parse name & attributes
            en.Name = el.Name.ToString();
            foreach (var attr in el.Attributes())
            {
                en.Attributes[attr.Name.ToString()] = attr.Value;
            }

            // parse nodes
            foreach (var node in el.Nodes())
            {
                var pn = Create(node, index, list);
                en.Tokens.AddLast(pn);
                index += pn.Length;
            }
        }
Exemplo n.º 4
0
 public RootToken(XElement root, RangeList rangeList)
     : base(0, rangeList)
 {
     ParseElement(this, root, 0, _rangeList);
 }
Exemplo n.º 5
0
 protected ParseToken(RangeList rangeList)
 {
     _rangeList = rangeList;
     Tokens = new LinkedList<ParseToken>();
 }
Exemplo n.º 6
0
 private TextToken(RangeList rangeList)
     : base(rangeList)
 {
 }
Exemplo n.º 7
0
 public TextToken(int index, int len, RangeList rangeList)
     : base(rangeList)
 {
     Range = _rangeList.AddRange(index, len);
 }
Exemplo n.º 8
0
 static void RemoveWhitespaces(RootToken rt, RangeList list)
 {
     //var i1 = Clear(rt.StartIndex, rt, list);
     //ClearRange(i1, rt.EndIndex, list);
 }