System.Net.WebPermission.IsSubsetOf C# (CSharp) Method

IsSubsetOf() public method

public IsSubsetOf ( IPermission target ) : bool
target IPermission
return bool
        public override bool IsSubsetOf(IPermission target) {
            // Pattern suggested by security engine
            if (target == null) {
                return !m_noRestriction && !m_UnrestrictedConnect && !m_UnrestrictedAccept && m_connectList.Count == 0 && m_acceptList.Count == 0;
            }

            WebPermission other = target as WebPermission;
            if (other == null) {
                throw new ArgumentException(SR.GetString(SR.net_perm_target), "target");
            }

            if (other.m_noRestriction)
            {
                return true;
            }
            else if (m_noRestriction)
            {
                return false;
            }

            //
            // Besides SPECIAL case, this method is restricted to only final URIs (strings) on
            // the current object.
            // The restriction comes from the problem of finding a Regex to be a subset of another Regex
            //
            DelayedRegex regex = null;

            if (!other.m_UnrestrictedAccept)
            {
                if (m_UnrestrictedAccept)
                {
                    return false;
                }
                else if (m_acceptList.Count != 0)
                {
                    if (other.m_acceptList.Count == 0)
                    {
                        return false;
                    }
                    foreach(object obj in this.m_acceptList) {
                        regex = obj as DelayedRegex;
                        if(regex != null) {
                            if(isSpecialSubsetCase(obj.ToString(), other.m_acceptList))
                                continue;
                            throw new NotSupportedException(SR.GetString(SR.net_perm_both_regex));
                        }
                        if(!isMatchedURI(obj, other.m_acceptList))
                            return false;
                    }
                }
            }

            if (!other.m_UnrestrictedConnect)
            {
                if (m_UnrestrictedConnect)
                {
                    return false;
                }
                else if (m_connectList.Count != 0)
                {
                    if (other.m_connectList.Count == 0)
                    {
                        return false;
                    }
                    foreach(object obj in this.m_connectList) {
                        regex = obj as DelayedRegex;
                        if(regex != null) {
                            if(isSpecialSubsetCase(obj.ToString(), other.m_connectList))
                                continue;
                            throw new NotSupportedException(SR.GetString(SR.net_perm_both_regex));
                        }
                        if(!isMatchedURI(obj, other.m_connectList))
                            return false;
                    }
                }
            }

            return true;
        }