protected override void UnregisterResource(string name) { Guard.ArgumentNotNullOrEmpty(name, "name"); lock (_lock) { // contains checks if (!_resources.ContainsKey(name)) { throw new KeyNotFoundException(string.Format(RESOURCE_NOTFOUND, typeof(T), name)); } // we get the locator and dispose it to release any resources IResourceLocator _locator = _resources[name]; if (_locator != null) { _locator.Dispose(); } // and remove, and change the default resource name _resources.Remove(name); if (string.Equals(_defaultResourceName, name, StringComparison.InvariantCultureIgnoreCase)) { _defaultResourceName = null; } // notify collection changed var _collectionChanged = CollectionChanged; if (_collectionChanged != null) { _collectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, _locator, -1)); } } }