void RemoveConfigImpl(string configPath, BaseConfigurationRecord configRecord) {
if (!ConfigPathUtility.IsValid(configPath)) {
throw ExceptionUtil.ParameterInvalid("configPath");
}
string[] parts = ConfigPathUtility.GetParts(configPath);
BaseConfigurationRecord currentRecord;
// search under exclusive writer lock
try {
int index;
AcquireHierarchyLockForWrite();
hlFindConfigRecord(parts, out index, out currentRecord);
// Return if not found, or does not match the one we are trying to remove.
if (index != parts.Length || (configRecord != null && !Object.ReferenceEquals(configRecord, currentRecord)))
return;
// Remove it from the hierarchy.
currentRecord.Parent.hlRemoveChild(parts[parts.Length - 1]);
}
finally {
ReleaseHierarchyLockForWrite();
}
OnConfigRemoved(new InternalConfigEventArgs(configPath));
// Close the record. This is safe to do outside the lock.
currentRecord.CloseRecursive();
}