private AddAsPattern ( NetworkAccess access, |
||
access | NetworkAccess | |
uriRegexPattern | ||
return | void |
/* * public bool ConnectAll * { * get * { * return m_connect is bool ? (bool) m_connect : false; * } * * set * { * if (m_connect != null) * { * throw new ArgumentException(SR.GetString(SR.net_perm_attrib_multi, "ConnectAll", value), "value"); * } * m_connect = value; * } * } * * public bool AcceptAll * { * get * { * return m_accept is bool ? (bool) m_accept : false; * } * * set * { * if (m_accept != null) * { * throw new ArgumentException(SR.GetString(SR.net_perm_attrib_multi, "AcceptAll", value), "value"); * } * m_accept = value; * } * } */ public override IPermission CreatePermission() { WebPermission perm = null; if (Unrestricted) { perm = new WebPermission(PermissionState.Unrestricted); } else { NetworkAccess access = (NetworkAccess)0; if (m_connect is bool) { if ((bool)m_connect) { access |= NetworkAccess.Connect; } m_connect = null; } if (m_accept is bool) { if ((bool)m_accept) { access |= NetworkAccess.Accept; } m_accept = null; } perm = new WebPermission(access); if (m_accept != null) { if (m_accept is DelayedRegex) { perm.AddAsPattern(NetworkAccess.Accept, (DelayedRegex)m_accept); } else { perm.AddPermission(NetworkAccess.Accept, (string)m_accept); } } if (m_connect != null) { if (m_connect is DelayedRegex) { perm.AddAsPattern(NetworkAccess.Connect, (DelayedRegex)m_connect); } else { perm.AddPermission(NetworkAccess.Connect, (string)m_connect); } } } return(perm); }
public override IPermission CreatePermission() { WebPermission permission = null; if (base.Unrestricted) { return(new WebPermission(PermissionState.Unrestricted)); } NetworkAccess access = 0; if (this.m_connect is bool) { if ((bool)this.m_connect) { access |= NetworkAccess.Connect; } this.m_connect = null; } if (this.m_accept is bool) { if ((bool)this.m_accept) { access |= NetworkAccess.Accept; } this.m_accept = null; } permission = new WebPermission(access); if (this.m_accept != null) { if (this.m_accept is DelayedRegex) { permission.AddAsPattern(NetworkAccess.Accept, (DelayedRegex)this.m_accept); } else { permission.AddPermission(NetworkAccess.Accept, (string)this.m_accept); } } if (this.m_connect != null) { if (this.m_connect is DelayedRegex) { permission.AddAsPattern(NetworkAccess.Connect, (DelayedRegex)this.m_connect); return(permission); } permission.AddPermission(NetworkAccess.Connect, (string)this.m_connect); } return(permission); }
public override IPermission CreatePermission() { WebPermission permission = null; if (base.Unrestricted) { return new WebPermission(PermissionState.Unrestricted); } NetworkAccess access = 0; if (this.m_connect is bool) { if ((bool) this.m_connect) { access |= NetworkAccess.Connect; } this.m_connect = null; } if (this.m_accept is bool) { if ((bool) this.m_accept) { access |= NetworkAccess.Accept; } this.m_accept = null; } permission = new WebPermission(access); if (this.m_accept != null) { if (this.m_accept is DelayedRegex) { permission.AddAsPattern(NetworkAccess.Accept, (DelayedRegex) this.m_accept); } else { permission.AddPermission(NetworkAccess.Accept, (string) this.m_accept); } } if (this.m_connect != null) { if (this.m_connect is DelayedRegex) { permission.AddAsPattern(NetworkAccess.Connect, (DelayedRegex) this.m_connect); return permission; } permission.AddPermission(NetworkAccess.Connect, (string) this.m_connect); } return permission; }
public override IPermission Union(IPermission target) { if (target == null) { return this.Copy(); } WebPermission permission = target as WebPermission; if (permission == null) { throw new ArgumentException(SR.GetString("net_perm_target"), "target"); } if (this.m_noRestriction || permission.m_noRestriction) { return new WebPermission(true); } WebPermission permission2 = new WebPermission(); if (this.m_UnrestrictedConnect || permission.m_UnrestrictedConnect) { permission2.m_UnrestrictedConnect = true; } else { permission2.m_connectList = (ArrayList) permission.m_connectList.Clone(); for (int j = 0; j < this.m_connectList.Count; j++) { DelayedRegex uriRegexPattern = this.m_connectList[j] as DelayedRegex; if (uriRegexPattern == null) { if (this.m_connectList[j] is string) { permission2.AddPermission(NetworkAccess.Connect, (string) this.m_connectList[j]); } else { permission2.AddPermission(NetworkAccess.Connect, (Uri) this.m_connectList[j]); } } else { permission2.AddAsPattern(NetworkAccess.Connect, uriRegexPattern); } } } if (this.m_UnrestrictedAccept || permission.m_UnrestrictedAccept) { permission2.m_UnrestrictedAccept = true; return permission2; } permission2.m_acceptList = (ArrayList) permission.m_acceptList.Clone(); for (int i = 0; i < this.m_acceptList.Count; i++) { DelayedRegex regex2 = this.m_acceptList[i] as DelayedRegex; if (regex2 == null) { if (this.m_acceptList[i] is string) { permission2.AddPermission(NetworkAccess.Accept, (string) this.m_acceptList[i]); } else { permission2.AddPermission(NetworkAccess.Accept, (Uri) this.m_acceptList[i]); } } else { permission2.AddAsPattern(NetworkAccess.Accept, regex2); } } return permission2; }
public override IPermission Union(IPermission target) { if (target == null) { return(this.Copy()); } WebPermission permission = target as WebPermission; if (permission == null) { throw new ArgumentException(SR.GetString("net_perm_target"), "target"); } if (this.m_noRestriction || permission.m_noRestriction) { return(new WebPermission(true)); } WebPermission permission2 = new WebPermission(); if (this.m_UnrestrictedConnect || permission.m_UnrestrictedConnect) { permission2.m_UnrestrictedConnect = true; } else { permission2.m_connectList = (ArrayList)permission.m_connectList.Clone(); for (int j = 0; j < this.m_connectList.Count; j++) { DelayedRegex uriRegexPattern = this.m_connectList[j] as DelayedRegex; if (uriRegexPattern == null) { if (this.m_connectList[j] is string) { permission2.AddPermission(NetworkAccess.Connect, (string)this.m_connectList[j]); } else { permission2.AddPermission(NetworkAccess.Connect, (Uri)this.m_connectList[j]); } } else { permission2.AddAsPattern(NetworkAccess.Connect, uriRegexPattern); } } } if (this.m_UnrestrictedAccept || permission.m_UnrestrictedAccept) { permission2.m_UnrestrictedAccept = true; return(permission2); } permission2.m_acceptList = (ArrayList)permission.m_acceptList.Clone(); for (int i = 0; i < this.m_acceptList.Count; i++) { DelayedRegex regex2 = this.m_acceptList[i] as DelayedRegex; if (regex2 == null) { if (this.m_acceptList[i] is string) { permission2.AddPermission(NetworkAccess.Accept, (string)this.m_acceptList[i]); } else { permission2.AddPermission(NetworkAccess.Accept, (Uri)this.m_acceptList[i]); } } else { permission2.AddAsPattern(NetworkAccess.Accept, regex2); } } return(permission2); }
// The union of two web permissions is formed by concatenating // the list of allowed regular expressions. There is no check // for duplicates/overlaps /// <devdoc> /// <para>Returns the logical union between two <see cref='System.Net.WebPermission'/> instances.</para> /// </devdoc> public override IPermission Union(IPermission target) { // Pattern suggested by Security engine if (target==null) { return this.Copy(); } WebPermission other = target as WebPermission; if(other == null) { throw new ArgumentException(SR.GetString(SR.net_perm_target), "target"); } if (m_noRestriction || other.m_noRestriction) { return new WebPermission(true); } WebPermission result = new WebPermission(); if (m_UnrestrictedConnect || other.m_UnrestrictedConnect) { result.m_UnrestrictedConnect = true; } else { result.m_connectList = (ArrayList) other.m_connectList.Clone(); for (int i = 0; i < m_connectList.Count; i++) { DelayedRegex uriPattern = m_connectList[i] as DelayedRegex; if(uriPattern == null) if (m_connectList[i] is string) result.AddPermission(NetworkAccess.Connect, (string)m_connectList[i]); else result.AddPermission(NetworkAccess.Connect, (Uri)m_connectList[i]); else result.AddAsPattern(NetworkAccess.Connect, uriPattern); } } if (m_UnrestrictedAccept || other.m_UnrestrictedAccept) { result.m_UnrestrictedAccept = true; } else { result.m_acceptList = (ArrayList) other.m_acceptList.Clone(); for (int i = 0; i < m_acceptList.Count; i++) { DelayedRegex uriPattern = m_acceptList[i] as DelayedRegex; if(uriPattern == null) if (m_acceptList[i] is string) result.AddPermission(NetworkAccess.Accept, (string)m_acceptList[i]); else result.AddPermission(NetworkAccess.Accept, (Uri)m_acceptList[i]); else result.AddAsPattern(NetworkAccess.Accept, uriPattern); } } return result; }
/* public bool ConnectAll { get { return m_connect is bool ? (bool) m_connect : false; } set { if (m_connect != null) { throw new ArgumentException(SR.GetString(SR.net_perm_attrib_multi, "ConnectAll", value), "value"); } m_connect = value; } } public bool AcceptAll { get { return m_accept is bool ? (bool) m_accept : false; } set { if (m_accept != null) { throw new ArgumentException(SR.GetString(SR.net_perm_attrib_multi, "AcceptAll", value), "value"); } m_accept = value; } } */ public override IPermission CreatePermission() { WebPermission perm = null; if (Unrestricted) { perm = new WebPermission( PermissionState.Unrestricted); } else { NetworkAccess access = (NetworkAccess) 0; if (m_connect is bool) { if ((bool) m_connect) { access |= NetworkAccess.Connect; } m_connect = null; } if (m_accept is bool) { if ((bool) m_accept) { access |= NetworkAccess.Accept; } m_accept = null; } perm = new WebPermission(access); if (m_accept != null) { if (m_accept is DelayedRegex) { perm.AddAsPattern(NetworkAccess.Accept, (DelayedRegex)m_accept); } else { perm.AddPermission(NetworkAccess.Accept, (string)m_accept); } } if (m_connect != null) { if (m_connect is DelayedRegex) { perm.AddAsPattern(NetworkAccess.Connect, (DelayedRegex)m_connect); } else { perm.AddPermission(NetworkAccess.Connect, (string)m_connect); } } } return perm; }
// The union of two web permissions is formed by concatenating // the list of allowed regular expressions. There is no check // for duplicates/overlaps /// <devdoc> /// <para>Returns the logical union between two <see cref='System.Net.WebPermission'/> instances.</para> /// </devdoc> public override IPermission Union(IPermission target) { // Pattern suggested by Security engine if (target == null) { return(this.Copy()); } WebPermission other = target as WebPermission; if (other == null) { throw new ArgumentException(SR.GetString(SR.net_perm_target), "target"); } if (m_noRestriction || other.m_noRestriction) { return(new WebPermission(true)); } WebPermission result = new WebPermission(); if (m_UnrestrictedConnect || other.m_UnrestrictedConnect) { result.m_UnrestrictedConnect = true; } else { result.m_connectList = (ArrayList)other.m_connectList.Clone(); for (int i = 0; i < m_connectList.Count; i++) { DelayedRegex uriPattern = m_connectList[i] as DelayedRegex; if (uriPattern == null) { if (m_connectList[i] is string) { result.AddPermission(NetworkAccess.Connect, (string)m_connectList[i]); } else { result.AddPermission(NetworkAccess.Connect, (Uri)m_connectList[i]); } } else { result.AddAsPattern(NetworkAccess.Connect, uriPattern); } } } if (m_UnrestrictedAccept || other.m_UnrestrictedAccept) { result.m_UnrestrictedAccept = true; } else { result.m_acceptList = (ArrayList)other.m_acceptList.Clone(); for (int i = 0; i < m_acceptList.Count; i++) { DelayedRegex uriPattern = m_acceptList[i] as DelayedRegex; if (uriPattern == null) { if (m_acceptList[i] is string) { result.AddPermission(NetworkAccess.Accept, (string)m_acceptList[i]); } else { result.AddPermission(NetworkAccess.Accept, (Uri)m_acceptList[i]); } } else { result.AddAsPattern(NetworkAccess.Accept, uriPattern); } } } return(result); }