System.Data.Common.DBConnectionString.Intersect C# (CSharp) Méthode

Intersect() private méthode

private Intersect ( DBConnectionString entry ) : DBConnectionString
entry DBConnectionString
Résultat DBConnectionString
        internal DBConnectionString Intersect(DBConnectionString entry)
        {
            KeyRestrictionBehavior behavior = _behavior;
            string[] restrictionValues = null;

            if (null == entry)
            {
                behavior = KeyRestrictionBehavior.AllowOnly;
            }
            else if (_behavior != entry._behavior)
            {
                // subset of the AllowOnly array
                behavior = KeyRestrictionBehavior.AllowOnly;

                if (KeyRestrictionBehavior.AllowOnly == entry._behavior)
                {
                    // this PreventUsage and entry AllowOnly
                    if (!ADP.IsEmptyArray(_restrictionValues))
                    {
                        if (!ADP.IsEmptyArray(entry._restrictionValues))
                        {
                            restrictionValues = NewRestrictionAllowOnly(entry._restrictionValues, _restrictionValues);
                        }
                    }
                    else
                    {
                        restrictionValues = entry._restrictionValues;
                    }
                }
                else if (!ADP.IsEmptyArray(_restrictionValues))
                {
                    // this AllowOnly and entry PreventUsage
                    if (!ADP.IsEmptyArray(entry._restrictionValues))
                    {
                        restrictionValues = NewRestrictionAllowOnly(_restrictionValues, entry._restrictionValues);
                    }
                    else
                    {
                        restrictionValues = _restrictionValues;
                    }
                }
            }
            else if (KeyRestrictionBehavior.PreventUsage == _behavior)
            {
                // both PreventUsage
                if (ADP.IsEmptyArray(_restrictionValues))
                {
                    restrictionValues = entry._restrictionValues;
                }
                else if (ADP.IsEmptyArray(entry._restrictionValues))
                {
                    restrictionValues = _restrictionValues;
                }
                else
                {
                    restrictionValues = NoDuplicateUnion(_restrictionValues, entry._restrictionValues);
                }
            }
            else if (!ADP.IsEmptyArray(_restrictionValues) && !ADP.IsEmptyArray(entry._restrictionValues))
            {
                // both AllowOnly with restrictions
                if (_restrictionValues.Length <= entry._restrictionValues.Length)
                {
                    restrictionValues = NewRestrictionIntersect(_restrictionValues, entry._restrictionValues);
                }
                else
                {
                    restrictionValues = NewRestrictionIntersect(entry._restrictionValues, _restrictionValues);
                }
            }

            // verify _hasPassword & _parsetable are in sync between Everett/Whidbey
            Debug.Assert(!_hasPassword || ContainsKey(KEY.Password) || ContainsKey(KEY.Pwd), "OnDeserialized password mismatch this");
            Debug.Assert(null == entry || !entry._hasPassword || entry.ContainsKey(KEY.Password) || entry.ContainsKey(KEY.Pwd), "OnDeserialized password mismatch entry");

            DBConnectionString value = new DBConnectionString(this, restrictionValues, behavior);
            ValidateCombinedSet(this, value);
            ValidateCombinedSet(entry, value);

            return value;
        }

Usage Example

Exemple #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;
                    }
                }
            }
        }
All Usage Examples Of System.Data.Common.DBConnectionString::Intersect