// gets the parsed version of a string expression
public Expression this[string expression]
{
get
{
Expression x = null;
WeakReference wr;
// get expression from cache
if (_dct.TryGetValue(expression, out wr))
{
x = wr.Target as Expression;
}
// if failed, parse now and store
if (x == null)
{
// remove all dead references from dictionary
if (_dct.Count > 100 && _hitCount++ > 100)
{
RemoveDeadReferences();
_hitCount = 0;
}
// store this expression
x = _ce.Parse(expression);
_dct[expression] = new WeakReference(x);
}
// return the parsed expression
return(x);
}
}