private bool IsContentSubset(object currentContent, object targetContent) {
//
if (currentContent is int) {
int currentAccess = (int)currentContent;
int targetAccess = (int)targetContent;
if ((currentAccess & targetAccess) != currentAccess)
return false;
return true;
}
else {
Hashtable currentContentTable = (Hashtable)currentContent;
Hashtable targetContentTable = (Hashtable)targetContent;
//If the target table contains a wild card, all the current entries need to be
//a subset of the target.
object targetAnyContent = targetContentTable[Any];
if (targetAnyContent != null) {
foreach(DictionaryEntry currentEntry in currentContentTable) {
if (!IsContentSubset(currentEntry.Value, targetAnyContent)) {
return false;
}
}
return true;
}
//Check the entries for remote machines first
foreach(DictionaryEntry currentEntry in currentContentTable) {
string currentContentKey = (string)currentEntry.Key;
if (currentContentKey != Local && currentContentKey != ComputerName) {
if (!targetContentTable.ContainsKey(currentContentKey)) {
return false;
}
else if (!IsContentSubset(currentEntry.Value, targetContentTable[currentContentKey])) {
return false;
}
}
}
// Entries for "." and local machine name apply to the same target.
// Merge them before further processing.
object currentLocalMergedContent = MergeContents(currentContentTable[Local], currentContentTable[ComputerName]);
if (currentLocalMergedContent != null ) {
object targetLocalMergedContent = MergeContents(targetContentTable[Local], targetContentTable[ComputerName]);
if (targetLocalMergedContent != null) {
return IsContentSubset(currentLocalMergedContent, targetLocalMergedContent);
}
else if (!IsEmpty) {
return false;
}
}
return true;
}
}