System.Data.Common.DBConnectionString.IsSupersetOf C# (CSharp) Method

IsSupersetOf() private method

private IsSupersetOf ( DBConnectionString entry ) : bool
entry DBConnectionString
return bool
        internal bool IsSupersetOf(DBConnectionString entry)
        {
            Debug.Assert(!_hasPassword || ContainsKey(KEY.Password) || ContainsKey(KEY.Pwd), "OnDeserialized password mismatch this");
            Debug.Assert(!entry._hasPassword || entry.ContainsKey(KEY.Password) || entry.ContainsKey(KEY.Pwd), "OnDeserialized password mismatch entry");

            switch (_behavior)
            {
                case KeyRestrictionBehavior.AllowOnly:
                    // every key must either be in the resticted connection string or in the allowed keywords
                    // keychain may contain duplicates, but it is better than GetEnumerator on _parsetable.Keys
                    for (NameValuePair current = entry.KeyChain; null != current; current = current.Next)
                    {
                        if (!ContainsKey(current.Name) && IsRestrictedKeyword(current.Name))
                        {
                            return false;
                        }
                    }
                    break;
                case KeyRestrictionBehavior.PreventUsage:
                    // every key can not be in the restricted keywords (even if in the restricted connection string)
                    if (null != _restrictionValues)
                    {
                        foreach (string restriction in _restrictionValues)
                        {
                            if (entry.ContainsKey(restriction))
                            {
                                return false;
                            }
                        }
                    }
                    break;
                default:
                    Debug.Assert(false, "invalid KeyRestrictionBehavior");
                    throw ADP.InvalidKeyRestrictionBehavior(_behavior);
            }
            return true;
        }

Usage Example

        internal bool CheckValueForKeyPermit(DBConnectionString parsetable)
        {
            if (parsetable == null)
            {
                return(false);
            }
            bool isEmpty = false;

            NameValuePermission[] permissionArray = this._tree;
            if (permissionArray != null)
            {
                isEmpty = parsetable.IsEmpty;
                if (!isEmpty)
                {
                    for (int i = 0; i < permissionArray.Length; i++)
                    {
                        NameValuePermission permission = permissionArray[i];
                        if (permission != null)
                        {
                            string keyword = permission._value;
                            if (parsetable.ContainsKey(keyword))
                            {
                                string keyInQuestion            = parsetable[keyword];
                                NameValuePermission permission2 = permission.CheckKeyForValue(keyInQuestion);
                                if ((permission2 != null) && permission2.CheckValueForKeyPermit(parsetable))
                                {
                                    isEmpty = true;
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }
            DBConnectionString str = this._entry;

            if (str != null)
            {
                isEmpty = str.IsSupersetOf(parsetable);
            }
            return(isEmpty);
        }
All Usage Examples Of System.Data.Common.DBConnectionString::IsSupersetOf