public virtual PropertyDescriptor Find(string name, bool ignoreCase) {
lock(this) {
PropertyDescriptor p = null;
if (cachedFoundProperties == null || cachedIgnoreCase != ignoreCase) {
cachedIgnoreCase = ignoreCase;
cachedFoundProperties = new HybridDictionary(ignoreCase);
}
// first try to find it in the cache
//
object cached = cachedFoundProperties[name];
if (cached != null) {
return (PropertyDescriptor) cached;
}
// Now start walking from where we last left off, filling
// the cache as we go.
//
for(int i = 0; i < propCount; i++) {
if (ignoreCase) {
if (String.Equals(properties[i].Name, name, StringComparison.OrdinalIgnoreCase)) {
cachedFoundProperties[name] = properties[i];
p = properties[i];
break;
}
}
else {
if (properties[i].Name.Equals(name)) {
cachedFoundProperties[name] = properties[i];
p = properties[i];
break;
}
}
}
return p;
}
}