For the interested, I was able to get this to work throught
ControlBuilder.Init function. It took awhile to figure out because there is
no documentation:
private class NumericPointerBuilder : ControlBuilder
{
public override void Init(TemplateParser parser, ControlBuilder
parentBuilder, Type type, string tagName, string id, IDictionary attribs)
{
IDictionary order = new Order(attribs);
base.Init(parser, parentBuilder, type, tagName, id, order);
}
private class Order : Hashtable
{
public Order(IDictionary items)
: base(items)
{
}
public override IDictionaryEnumerator GetEnumerator()
{
return new Enumerator(this);
}
private class Enumerator : IDictionaryEnumerator
{
private const string ValueProperty = "Value";
private const string RangeProperty = "Range";
private List<DictionaryEntry> _list;
private int _currentIndex;
public Enumerator(Hashtable hashTable)
{
_currentIndex = -1;
_list = new List<DictionaryEntry>();
// getting the IEnumerable interface to call the
explicit implementation
// to aviod a recrusive stack overflow here.
IEnumerable enumerable = hashTable;
int valueKeyIndex = -1;
foreach (DictionaryEntry entry in enumerable)
{
if (entry.Key is string && ((string)entry.Key)
== ValueProperty)
{
valueKeyIndex = _list.Count;
}
if (entry.Key is string && ((string)entry.Key)
== RangeProperty)
{
//Value property has been added
if (valueKeyIndex != -1)
{
//Insert range property before Value
property.
_list.Insert(valueKeyIndex, entry);
continue;
}
}
_list.Add(entry);
}
}
public void Reset()
{
_currentIndex = -1;
}
public object Current
{
get
{
return Entry;
}
}
public bool MoveNext()
{
_currentIndex++;
if (_currentIndex >= _list.Count)
{
_currentIndex = _list.Count;
return false;
}
return true;
}
public DictionaryEntry Entry
{
get
{
if (_currentIndex < _list.Count && _currentIndex
Quote:
= 0)
return _list[_currentIndex];
|
else
throw ExceptionBuilder.InvalidOperation();
}
}
public object Key
{
get
{
return Entry.Key;
}
}
public object Value
{
get
{
return Entry.Value;
}
}
}
}
}