System.Data.Common.DBDataPermission.IsEmpty()

Here are the examples of the csharp api class System.Data.Common.DBDataPermission.IsEmpty() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

1. Example

Project: referencesource
Source File: DBDataPermission.cs
View license
override public bool IsSubsetOf(IPermission target) {
            if (null == target) {
                return IsEmpty();
            }
            if (target.GetType() != this.GetType()) {
                throw ADP.PermissionTypeMismatch();
            }

            DBDataPermission superset = (target as DBDataPermission);

            bool subset = superset.IsUnrestricted();
            if (!subset) {
                if (!IsUnrestricted() &&
                    (!AllowBlankPassword || superset.AllowBlankPassword) &&
                    ((null == _keyvalues) || (null != superset._keyvaluetree))) {

                    subset = true;
                    if (null != _keyvalues) {
                        foreach(DBConnectionString kventry in _keyvalues) {
                            if(!superset._keyvaluetree.CheckValueForKeyPermit(kventry)) {
                                subset = false;
                                break;
                            }
                        }
                    }
                }
            }
            return subset;
        }

2. Example

Project: referencesource
Source File: DBDataPermission.cs
View license
override public IPermission Intersect(IPermission target) { // used during Deny actions
            if (null == target) {
                return null;
            }
            if (target.GetType() != this.GetType()) {
                throw ADP.PermissionTypeMismatch();
            }
            if (this.IsUnrestricted()) { // MDAC 84803, NDPWhidbey 29121
                return target.Copy();
            }

            DBDataPermission operand = (DBDataPermission) target;
            if (operand.IsUnrestricted()) { // NDPWhidbey 29121
                return this.Copy();
            }

            DBDataPermission newPermission = (DBDataPermission) operand.Copy();
            newPermission._allowBlankPassword &= AllowBlankPassword;

            if ((null != _keyvalues) && (null != newPermission._keyvalues)) {
                newPermission._keyvalues.Clear();

                newPermission._keyvaluetree.Intersect(newPermission._keyvalues, _keyvaluetree);
            }
            else {
                // either target.Add or this.Add have not been called
                // return a non-null object so IsSubset calls will fail
                newPermission._keyvalues = null;
                newPermission._keyvaluetree = null;
            }

            if (newPermission.IsEmpty()) { // no intersection, MDAC 86773
                newPermission = null;
            }
            return newPermission;
        }

3. Example

Project: referencesource
Source File: DBDataPermission.cs
View license
override public IPermission Union(IPermission target) {
            if (null == target) {
                return this.Copy();
            }
            if (target.GetType() != this.GetType()) {
                throw ADP.PermissionTypeMismatch();
            }
            if (IsUnrestricted()) { // MDAC 84803
                return this.Copy();
            }

            DBDataPermission newPermission = (DBDataPermission) target.Copy();
            if (!newPermission.IsUnrestricted()) {
                newPermission._allowBlankPassword |= AllowBlankPassword;

                if (null != _keyvalues) {
                    foreach(DBConnectionString entry in _keyvalues) {
                        newPermission.AddPermissionEntry(entry);
                    }
                }
            }
            return (newPermission.IsEmpty() ? null : newPermission);
        }