public static void Refresh(object component) {
if (component == null) {
return;
}
// COM objects aren't cached since we don't
// want to be holding references to them.
if (System.Runtime.InteropServices.Marshal.IsComObject(component)) {
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.
//
ComponentEntry entry = null;
lock(cachedComponentEntries) {
entry = (ComponentEntry)cachedComponentEntries[component.GetType()];
}
if (entry != null) {
// Clear the attribute cache. It's not that expensive to build
// this back up if we need to.
//
lock(attributeCache) {
attributeCache.Clear();
}
// Remove the item from the cache, it will get recreated
// on demand.
//
lock(cachedComponentEntries) {
cachedComponentEntries.Remove(component.GetType());
}
// Allow the entry to dispose itself.
//
entry.Dispose(component);
// Notify listeners of the change
//
RefreshEventHandler handler = refreshHandler;
if (handler != null) {
handler(new RefreshEventArgs(component));
}
}
}