static internal void AddEntry(NameValuePermission kvtree, ArrayList entries, DBConnectionString entry) { Debug.Assert(null != entry, "null DBConnectionString"); if (null != entry.KeyChain) { for (NameValuePair keychain = entry.KeyChain; null != keychain; keychain = keychain.Next) { NameValuePermission kv; kv = kvtree.CheckKeyForValue(keychain.Name); if (null == kv) { kv = new NameValuePermission(keychain.Name); kvtree.Add(kv); // add directly into live tree } kvtree = kv; kv = kvtree.CheckKeyForValue(keychain.Value); if (null == kv) { DBConnectionString insertValue = ((null != keychain.Next) ? null : entry); kv = new NameValuePermission(keychain.Value, insertValue); kvtree.Add(kv); // add directly into live tree if (null != insertValue) { entries.Add(insertValue); } } else if (null == keychain.Next) // shorter chain potential { if (null != kv._entry) { entries.Remove(kv._entry); kv._entry = kv._entry.MergeIntersect(entry); // union new restrictions into existing tree } else { kv._entry = entry; } entries.Add(kv._entry); } kvtree = kv; } } else // global restrictions, MDAC 84443 { DBConnectionString kentry = kvtree._entry; if (null != kentry) { entries.Remove(kentry); kvtree._entry = kentry.MergeIntersect(entry); } else { kvtree._entry = entry; } entries.Add(kvtree._entry); } }
internal void Intersect(ArrayList entries, NameValuePermission target) { if (null == target) { _tree = null; _entry = null; } else { if (null != _entry) { entries.Remove(_entry); _entry = _entry.MergeIntersect(target._entry); entries.Add(_entry); } else if (null != target._entry) { _entry = target._entry.MergeIntersect(null); entries.Add(_entry); } if (null != _tree) { int count = _tree.Length; for (int i = 0; i < _tree.Length; ++i) { NameValuePermission kvtree = target.CheckKeyForValue(_tree[i]._value); if (null != kvtree) // does target tree contain our value { _tree[i].Intersect(entries, kvtree); } else { _tree[i] = null; --count; } } if (0 == count) { _tree = null; } else if (count < _tree.Length) { NameValuePermission[] kvtree = new NameValuePermission[count]; for (int i = 0, j = 0; i < _tree.Length; ++i) { if (null != _tree[i]) { kvtree[j++] = _tree[i]; } } } } } }