public static void Refresh(Type type) {
if (type == null) {
return;
}
// We only fire the change event if we have cached the componet.
// Since we will recreate the cache entry if anyone has asked for
// this component... this prevents getting tons of duplicate
// Refresh events.
//
bool found = false;
lock (cachedComponentEntries) {
ArrayList removeItems = null;
// find all the instances of the requested type
// and any types that derive from it,
// and remove them.
//
foreach (Type cacheType in cachedComponentEntries.Keys) {
if (type.IsAssignableFrom(cacheType)) {
if (removeItems == null) {
removeItems = new ArrayList();
}
removeItems.Add(cacheType);
}
}
if (removeItems != null) {
foreach (Type t in removeItems) {
// Remove the item from the cache, it will get recreated
// on demand.
//
cachedComponentEntries.Remove(t);
}
found = true;
}
}
if (found) {
// Clear the attribute cache. It's not that expensive to build
// this back up if we need to.
//
lock(attributeCache) {
attributeCache.Clear();
}
RefreshEventHandler handler = refreshHandler;
// Notify listeners of the change
//
if (handler != null) {
handler(new RefreshEventArgs(type));
}
}
}