Intersect() private method

private Intersect ( DBConnectionString entry ) : DBConnectionString
entry DBConnectionString
return DBConnectionString
Exemplo n.º 1
0
        internal void Intersect(ArrayList entries, NameValuePermission target)
        {
            if (null == target)
            {
                _tree  = null;
                _entry = null;
            }
            else
            {
                if (null != _entry)
                {
                    entries.Remove(_entry);
                    _entry = _entry.Intersect(target._entry);
                    entries.Add(_entry);
                }
                else if (null != target._entry)
                {
                    _entry = target._entry.Intersect(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];
                            }
                        }
                        _tree = kvtree;
                    }
                }
            }
        }
 internal static void AddEntry(NameValuePermission kvtree, ArrayList entries, DBConnectionString entry)
 {
     if (entry.KeyChain != null)
     {
         for (NameValuePair pair = entry.KeyChain; pair != null; pair = pair.Next)
         {
             NameValuePermission permit = kvtree.CheckKeyForValue(pair.Name);
             if (permit == null)
             {
                 permit = new NameValuePermission(pair.Name);
                 kvtree.Add(permit);
             }
             kvtree = permit;
             permit = kvtree.CheckKeyForValue(pair.Value);
             if (permit == null)
             {
                 DBConnectionString str2 = (pair.Next != null) ? null : entry;
                 permit = new NameValuePermission(pair.Value, str2);
                 kvtree.Add(permit);
                 if (str2 != null)
                 {
                     entries.Add(str2);
                 }
             }
             else if (pair.Next == null)
             {
                 if (permit._entry != null)
                 {
                     entries.Remove(permit._entry);
                     permit._entry = permit._entry.Intersect(entry);
                 }
                 else
                 {
                     permit._entry = entry;
                 }
                 entries.Add(permit._entry);
             }
             kvtree = permit;
         }
     }
     else
     {
         DBConnectionString str = kvtree._entry;
         if (str != null)
         {
             entries.Remove(str);
             kvtree._entry = str.Intersect(entry);
         }
         else
         {
             kvtree._entry = entry;
         }
         entries.Add(kvtree._entry);
     }
 }
Exemplo n.º 3
0
        internal static 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)
                        {
                            Debug.Assert(entries.Contains(kv._entry), "entries doesn't contain entry");
                            entries.Remove(kv._entry);
                            kv._entry = kv._entry.Intersect(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)
                {
                    Debug.Assert(entries.Contains(kentry), "entries doesn't contain entry");
                    entries.Remove(kentry);
                    kvtree._entry = kentry.Intersect(entry);
                }
                else
                {
                    kvtree._entry = entry;
                }
                entries.Add(kvtree._entry);
            }
        }