mscorlib(4.0.0.0) API with additions
WebPermission.cs
1 using System.Collections;
3 using System.Security;
6 
7 namespace System.Net
8 {
10  [Serializable]
12  {
13  private bool m_noRestriction;
14 
15  [OptionalField]
16  private bool m_UnrestrictedConnect;
17 
18  [OptionalField]
19  private bool m_UnrestrictedAccept;
20 
21  private ArrayList m_connectList = new ArrayList();
22 
23  private ArrayList m_acceptList = new ArrayList();
24 
25  internal const string MatchAll = ".*";
26 
27  private static volatile Regex s_MatchAllRegex;
28 
29  internal static Regex MatchAllRegex
30  {
31  get
32  {
33  if (s_MatchAllRegex == null)
34  {
35  s_MatchAllRegex = new Regex(".*");
36  }
37  return s_MatchAllRegex;
38  }
39  }
40 
44  {
45  get
46  {
47  if (m_UnrestrictedConnect)
48  {
49  return new Regex[1]
50  {
51  MatchAllRegex
52  }.GetEnumerator();
53  }
54  ArrayList arrayList = new ArrayList(m_connectList.Count);
55  for (int i = 0; i < m_connectList.Count; i++)
56  {
57  arrayList.Add((m_connectList[i] is DelayedRegex) ? ((DelayedRegex)m_connectList[i]).AsRegex : ((m_connectList[i] is Uri) ? ((Uri)m_connectList[i]).GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped) : m_connectList[i]));
58  }
59  return arrayList.GetEnumerator();
60  }
61  }
62 
65  public IEnumerator AcceptList
66  {
67  get
68  {
69  if (m_UnrestrictedAccept)
70  {
71  return new Regex[1]
72  {
73  MatchAllRegex
74  }.GetEnumerator();
75  }
76  ArrayList arrayList = new ArrayList(m_acceptList.Count);
77  for (int i = 0; i < m_acceptList.Count; i++)
78  {
79  arrayList.Add((m_acceptList[i] is DelayedRegex) ? ((DelayedRegex)m_acceptList[i]).AsRegex : ((m_acceptList[i] is Uri) ? ((Uri)m_acceptList[i]).GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped) : m_acceptList[i]));
80  }
81  return arrayList.GetEnumerator();
82  }
83  }
84 
88  {
89  m_noRestriction = (state == PermissionState.Unrestricted);
90  }
91 
92  internal WebPermission(bool unrestricted)
93  {
94  m_noRestriction = unrestricted;
95  }
96 
98  public WebPermission()
99  {
100  }
101 
102  internal WebPermission(NetworkAccess access)
103  {
104  m_UnrestrictedConnect = ((access & NetworkAccess.Connect) != (NetworkAccess)0);
105  m_UnrestrictedAccept = ((access & NetworkAccess.Accept) != (NetworkAccess)0);
106  }
107 
111  public WebPermission(NetworkAccess access, Regex uriRegex)
112  {
113  AddPermission(access, uriRegex);
114  }
115 
121  public WebPermission(NetworkAccess access, string uriString)
122  {
123  AddPermission(access, uriString);
124  }
125 
126  internal WebPermission(NetworkAccess access, Uri uri)
127  {
128  AddPermission(access, uri);
129  }
130 
136  public void AddPermission(NetworkAccess access, string uriString)
137  {
138  if (uriString == null)
139  {
140  throw new ArgumentNullException("uriString");
141  }
142  if (m_noRestriction)
143  {
144  return;
145  }
146  if (Uri.TryCreate(uriString, UriKind.Absolute, out Uri result))
147  {
148  AddPermission(access, result);
149  return;
150  }
151  ArrayList arrayList = new ArrayList();
152  if ((access & NetworkAccess.Connect) != 0 && !m_UnrestrictedConnect)
153  {
154  arrayList.Add(m_connectList);
155  }
156  if ((access & NetworkAccess.Accept) != 0 && !m_UnrestrictedAccept)
157  {
158  arrayList.Add(m_acceptList);
159  }
160  foreach (ArrayList item in arrayList)
161  {
162  bool flag = false;
163  foreach (object item2 in item)
164  {
165  string text = item2 as string;
166  if (text != null && string.Compare(text, uriString, StringComparison.OrdinalIgnoreCase) == 0)
167  {
168  flag = true;
169  break;
170  }
171  }
172  if (!flag)
173  {
174  item.Add(uriString);
175  }
176  }
177  }
178 
179  internal void AddPermission(NetworkAccess access, Uri uri)
180  {
181  if (uri == null)
182  {
183  throw new ArgumentNullException("uri");
184  }
185  if (!m_noRestriction)
186  {
187  ArrayList arrayList = new ArrayList();
188  if ((access & NetworkAccess.Connect) != 0 && !m_UnrestrictedConnect)
189  {
190  arrayList.Add(m_connectList);
191  }
192  if ((access & NetworkAccess.Accept) != 0 && !m_UnrestrictedAccept)
193  {
194  arrayList.Add(m_acceptList);
195  }
196  foreach (ArrayList item in arrayList)
197  {
198  bool flag = false;
199  foreach (object item2 in item)
200  {
201  if (item2 is Uri && uri.Equals(item2))
202  {
203  flag = true;
204  break;
205  }
206  }
207  if (!flag)
208  {
209  item.Add(uri);
210  }
211  }
212  }
213  }
214 
219  public void AddPermission(NetworkAccess access, Regex uriRegex)
220  {
221  if (uriRegex == null)
222  {
223  throw new ArgumentNullException("uriRegex");
224  }
225  if (m_noRestriction)
226  {
227  return;
228  }
229  if (uriRegex.ToString() == ".*")
230  {
231  if (!m_UnrestrictedConnect && (access & NetworkAccess.Connect) != 0)
232  {
233  m_UnrestrictedConnect = true;
234  m_connectList.Clear();
235  }
236  if (!m_UnrestrictedAccept && (access & NetworkAccess.Accept) != 0)
237  {
238  m_UnrestrictedAccept = true;
239  m_acceptList.Clear();
240  }
241  }
242  else
243  {
244  AddAsPattern(access, new DelayedRegex(uriRegex));
245  }
246  }
247 
248  internal void AddAsPattern(NetworkAccess access, DelayedRegex uriRegexPattern)
249  {
250  ArrayList arrayList = new ArrayList();
251  if ((access & NetworkAccess.Connect) != 0 && !m_UnrestrictedConnect)
252  {
253  arrayList.Add(m_connectList);
254  }
255  if ((access & NetworkAccess.Accept) != 0 && !m_UnrestrictedAccept)
256  {
257  arrayList.Add(m_acceptList);
258  }
259  foreach (ArrayList item in arrayList)
260  {
261  bool flag = false;
262  foreach (object item2 in item)
263  {
264  if (item2 is DelayedRegex && string.Compare(uriRegexPattern.ToString(), item2.ToString(), StringComparison.OrdinalIgnoreCase) == 0)
265  {
266  flag = true;
267  break;
268  }
269  }
270  if (!flag)
271  {
272  item.Add(uriRegexPattern);
273  }
274  }
275  }
276 
280  public bool IsUnrestricted()
281  {
282  return m_noRestriction;
283  }
284 
287  public override IPermission Copy()
288  {
289  if (m_noRestriction)
290  {
291  return new WebPermission(unrestricted: true);
292  }
293  WebPermission webPermission = new WebPermission((NetworkAccess)((m_UnrestrictedConnect ? 64 : 0) | (m_UnrestrictedAccept ? 128 : 0)));
294  webPermission.m_acceptList = (ArrayList)m_acceptList.Clone();
295  webPermission.m_connectList = (ArrayList)m_connectList.Clone();
296  return webPermission;
297  }
298 
305  public override bool IsSubsetOf(IPermission target)
306  {
307  if (target == null)
308  {
309  if (!m_noRestriction && !m_UnrestrictedConnect && !m_UnrestrictedAccept && m_connectList.Count == 0)
310  {
311  return m_acceptList.Count == 0;
312  }
313  return false;
314  }
315  WebPermission webPermission = target as WebPermission;
316  if (webPermission == null)
317  {
318  throw new ArgumentException(SR.GetString("net_perm_target"), "target");
319  }
320  if (webPermission.m_noRestriction)
321  {
322  return true;
323  }
324  if (m_noRestriction)
325  {
326  return false;
327  }
328  DelayedRegex delayedRegex = null;
329  if (!webPermission.m_UnrestrictedAccept)
330  {
331  if (m_UnrestrictedAccept)
332  {
333  return false;
334  }
335  if (m_acceptList.Count != 0)
336  {
337  if (webPermission.m_acceptList.Count == 0)
338  {
339  return false;
340  }
341  foreach (object accept in m_acceptList)
342  {
343  delayedRegex = (accept as DelayedRegex);
344  if (delayedRegex != null)
345  {
346  if (!isSpecialSubsetCase(accept.ToString(), webPermission.m_acceptList))
347  {
348  throw new NotSupportedException(SR.GetString("net_perm_both_regex"));
349  }
350  }
351  else if (!isMatchedURI(accept, webPermission.m_acceptList))
352  {
353  return false;
354  }
355  }
356  }
357  }
358  if (!webPermission.m_UnrestrictedConnect)
359  {
360  if (m_UnrestrictedConnect)
361  {
362  return false;
363  }
364  if (m_connectList.Count != 0)
365  {
366  if (webPermission.m_connectList.Count == 0)
367  {
368  return false;
369  }
370  foreach (object connect in m_connectList)
371  {
372  delayedRegex = (connect as DelayedRegex);
373  if (delayedRegex != null)
374  {
375  if (!isSpecialSubsetCase(connect.ToString(), webPermission.m_connectList))
376  {
377  throw new NotSupportedException(SR.GetString("net_perm_both_regex"));
378  }
379  }
380  else if (!isMatchedURI(connect, webPermission.m_connectList))
381  {
382  return false;
383  }
384  }
385  }
386  }
387  return true;
388  }
389 
390  private static bool isSpecialSubsetCase(string regexToCheck, ArrayList permList)
391  {
392  foreach (object perm in permList)
393  {
394  DelayedRegex delayedRegex = perm as DelayedRegex;
395  Uri uri;
396  if (delayedRegex != null)
397  {
398  if (string.Compare(regexToCheck, delayedRegex.ToString(), StringComparison.OrdinalIgnoreCase) == 0)
399  {
400  return true;
401  }
402  }
403  else if ((uri = (perm as Uri)) != null)
404  {
405  if (string.Compare(regexToCheck, Regex.Escape(uri.GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped)), StringComparison.OrdinalIgnoreCase) == 0)
406  {
407  return true;
408  }
409  }
410  else if (string.Compare(regexToCheck, Regex.Escape(perm.ToString()), StringComparison.OrdinalIgnoreCase) == 0)
411  {
412  return true;
413  }
414  }
415  return false;
416  }
417 
422  public override IPermission Union(IPermission target)
423  {
424  if (target == null)
425  {
426  return Copy();
427  }
428  WebPermission webPermission = target as WebPermission;
429  if (webPermission == null)
430  {
431  throw new ArgumentException(SR.GetString("net_perm_target"), "target");
432  }
433  if (m_noRestriction || webPermission.m_noRestriction)
434  {
435  return new WebPermission(unrestricted: true);
436  }
437  WebPermission webPermission2 = new WebPermission();
438  if (m_UnrestrictedConnect || webPermission.m_UnrestrictedConnect)
439  {
440  webPermission2.m_UnrestrictedConnect = true;
441  }
442  else
443  {
444  webPermission2.m_connectList = (ArrayList)webPermission.m_connectList.Clone();
445  for (int i = 0; i < m_connectList.Count; i++)
446  {
447  DelayedRegex delayedRegex = m_connectList[i] as DelayedRegex;
448  if (delayedRegex == null)
449  {
450  if (m_connectList[i] is string)
451  {
452  webPermission2.AddPermission(NetworkAccess.Connect, (string)m_connectList[i]);
453  }
454  else
455  {
456  webPermission2.AddPermission(NetworkAccess.Connect, (Uri)m_connectList[i]);
457  }
458  }
459  else
460  {
461  webPermission2.AddAsPattern(NetworkAccess.Connect, delayedRegex);
462  }
463  }
464  }
465  if (m_UnrestrictedAccept || webPermission.m_UnrestrictedAccept)
466  {
467  webPermission2.m_UnrestrictedAccept = true;
468  }
469  else
470  {
471  webPermission2.m_acceptList = (ArrayList)webPermission.m_acceptList.Clone();
472  for (int j = 0; j < m_acceptList.Count; j++)
473  {
474  DelayedRegex delayedRegex2 = m_acceptList[j] as DelayedRegex;
475  if (delayedRegex2 == null)
476  {
477  if (m_acceptList[j] is string)
478  {
479  webPermission2.AddPermission(NetworkAccess.Accept, (string)m_acceptList[j]);
480  }
481  else
482  {
483  webPermission2.AddPermission(NetworkAccess.Accept, (Uri)m_acceptList[j]);
484  }
485  }
486  else
487  {
488  webPermission2.AddAsPattern(NetworkAccess.Accept, delayedRegex2);
489  }
490  }
491  }
492  return webPermission2;
493  }
494 
500  public override IPermission Intersect(IPermission target)
501  {
502  if (target == null)
503  {
504  return null;
505  }
506  WebPermission webPermission = target as WebPermission;
507  if (webPermission == null)
508  {
509  throw new ArgumentException(SR.GetString("net_perm_target"), "target");
510  }
511  if (m_noRestriction)
512  {
513  return webPermission.Copy();
514  }
515  if (webPermission.m_noRestriction)
516  {
517  return Copy();
518  }
519  WebPermission webPermission2 = new WebPermission();
520  if (m_UnrestrictedConnect && webPermission.m_UnrestrictedConnect)
521  {
522  webPermission2.m_UnrestrictedConnect = true;
523  }
524  else if (m_UnrestrictedConnect || webPermission.m_UnrestrictedConnect)
525  {
526  webPermission2.m_connectList = (ArrayList)(m_UnrestrictedConnect ? webPermission : this).m_connectList.Clone();
527  }
528  else
529  {
530  intersectList(m_connectList, webPermission.m_connectList, webPermission2.m_connectList);
531  }
532  if (m_UnrestrictedAccept && webPermission.m_UnrestrictedAccept)
533  {
534  webPermission2.m_UnrestrictedAccept = true;
535  }
536  else if (m_UnrestrictedAccept || webPermission.m_UnrestrictedAccept)
537  {
538  webPermission2.m_acceptList = (ArrayList)(m_UnrestrictedAccept ? webPermission : this).m_acceptList.Clone();
539  }
540  else
541  {
542  intersectList(m_acceptList, webPermission.m_acceptList, webPermission2.m_acceptList);
543  }
544  if (!webPermission2.m_UnrestrictedConnect && !webPermission2.m_UnrestrictedAccept && webPermission2.m_connectList.Count == 0 && webPermission2.m_acceptList.Count == 0)
545  {
546  return null;
547  }
548  return webPermission2;
549  }
550 
556  public override void FromXml(SecurityElement securityElement)
557  {
558  if (securityElement == null)
559  {
560  throw new ArgumentNullException("securityElement");
561  }
562  if (!securityElement.Tag.Equals("IPermission"))
563  {
564  throw new ArgumentException(SR.GetString("net_not_ipermission"), "securityElement");
565  }
566  string text = securityElement.Attribute("class");
567  if (text == null)
568  {
569  throw new ArgumentException(SR.GetString("net_no_classname"), "securityElement");
570  }
571  if (text.IndexOf(GetType().FullName) < 0)
572  {
573  throw new ArgumentException(SR.GetString("net_no_typename"), "securityElement");
574  }
575  string text2 = securityElement.Attribute("Unrestricted");
576  m_connectList = new ArrayList();
577  m_acceptList = new ArrayList();
578  m_UnrestrictedAccept = (m_UnrestrictedConnect = false);
579  if (text2 != null && string.Compare(text2, "true", StringComparison.OrdinalIgnoreCase) == 0)
580  {
581  m_noRestriction = true;
582  return;
583  }
584  m_noRestriction = false;
585  SecurityElement securityElement2 = securityElement.SearchForChildByTag("ConnectAccess");
586  if (securityElement2 != null)
587  {
588  foreach (SecurityElement child in securityElement2.Children)
589  {
590  if (child.Tag.Equals("URI"))
591  {
592  string text3;
593  try
594  {
595  text3 = child.Attribute("uri");
596  }
597  catch
598  {
599  text3 = null;
600  }
601  if (text3 == null)
602  {
603  throw new ArgumentException(SR.GetString("net_perm_invalid_val_in_element"), "ConnectAccess");
604  }
605  if (text3 == ".*")
606  {
607  m_UnrestrictedConnect = true;
608  m_connectList = new ArrayList();
609  break;
610  }
611  AddAsPattern(NetworkAccess.Connect, new DelayedRegex(text3));
612  }
613  }
614  }
615  securityElement2 = securityElement.SearchForChildByTag("AcceptAccess");
616  if (securityElement2 != null)
617  {
618  foreach (SecurityElement child2 in securityElement2.Children)
619  {
620  if (child2.Tag.Equals("URI"))
621  {
622  string text3;
623  try
624  {
625  text3 = child2.Attribute("uri");
626  }
627  catch
628  {
629  text3 = null;
630  }
631  if (text3 == null)
632  {
633  throw new ArgumentException(SR.GetString("net_perm_invalid_val_in_element"), "AcceptAccess");
634  }
635  if (text3 == ".*")
636  {
637  m_UnrestrictedAccept = true;
638  m_acceptList = new ArrayList();
639  break;
640  }
641  AddAsPattern(NetworkAccess.Accept, new DelayedRegex(text3));
642  }
643  }
644  }
645  }
646 
649  public override SecurityElement ToXml()
650  {
651  SecurityElement securityElement = new SecurityElement("IPermission");
652  securityElement.AddAttribute("class", GetType().FullName + ", " + GetType().Module.Assembly.FullName.Replace('"', '\''));
653  securityElement.AddAttribute("version", "1");
654  if (!IsUnrestricted())
655  {
656  string text = null;
657  if (m_UnrestrictedConnect || m_connectList.Count > 0)
658  {
659  SecurityElement securityElement2 = new SecurityElement("ConnectAccess");
660  if (m_UnrestrictedConnect)
661  {
662  SecurityElement securityElement3 = new SecurityElement("URI");
663  securityElement3.AddAttribute("uri", SecurityElement.Escape(".*"));
664  securityElement2.AddChild(securityElement3);
665  }
666  else
667  {
668  foreach (object connect in m_connectList)
669  {
670  Uri uri = connect as Uri;
671  text = ((!(uri != null)) ? connect.ToString() : Regex.Escape(uri.GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped)));
672  if (connect is string)
673  {
674  text = Regex.Escape(text);
675  }
676  SecurityElement securityElement4 = new SecurityElement("URI");
677  securityElement4.AddAttribute("uri", SecurityElement.Escape(text));
678  securityElement2.AddChild(securityElement4);
679  }
680  }
681  securityElement.AddChild(securityElement2);
682  }
683  if (m_UnrestrictedAccept || m_acceptList.Count > 0)
684  {
685  SecurityElement securityElement5 = new SecurityElement("AcceptAccess");
686  if (m_UnrestrictedAccept)
687  {
688  SecurityElement securityElement6 = new SecurityElement("URI");
689  securityElement6.AddAttribute("uri", SecurityElement.Escape(".*"));
690  securityElement5.AddChild(securityElement6);
691  }
692  else
693  {
694  foreach (object accept in m_acceptList)
695  {
696  Uri uri2 = accept as Uri;
697  text = ((!(uri2 != null)) ? accept.ToString() : Regex.Escape(uri2.GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped)));
698  if (accept is string)
699  {
700  text = Regex.Escape(text);
701  }
702  SecurityElement securityElement7 = new SecurityElement("URI");
703  securityElement7.AddAttribute("uri", SecurityElement.Escape(text));
704  securityElement5.AddChild(securityElement7);
705  }
706  }
707  securityElement.AddChild(securityElement5);
708  }
709  }
710  else
711  {
712  securityElement.AddAttribute("Unrestricted", "true");
713  }
714  return securityElement;
715  }
716 
717  private static bool isMatchedURI(object uriToCheck, ArrayList uriPatternList)
718  {
719  string text = uriToCheck as string;
720  foreach (object uriPattern in uriPatternList)
721  {
722  DelayedRegex delayedRegex = uriPattern as DelayedRegex;
723  if (delayedRegex == null)
724  {
725  if (uriToCheck.GetType() == uriPattern.GetType())
726  {
727  if (text != null && string.Compare(text, (string)uriPattern, StringComparison.OrdinalIgnoreCase) == 0)
728  {
729  return true;
730  }
731  if (text == null && uriToCheck.Equals(uriPattern))
732  {
733  return true;
734  }
735  }
736  }
737  else
738  {
739  string text2 = (text != null) ? text : ((Uri)uriToCheck).GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped);
740  Match match = delayedRegex.AsRegex.Match(text2);
741  if (match != null && match.Index == 0 && match.Length == text2.Length)
742  {
743  return true;
744  }
745  if (text == null)
746  {
747  text2 = ((Uri)uriToCheck).GetComponents(UriComponents.HttpRequestUrl, UriFormat.SafeUnescaped);
748  match = delayedRegex.AsRegex.Match(text2);
749  if (match != null && match.Index == 0 && match.Length == text2.Length)
750  {
751  return true;
752  }
753  }
754  }
755  }
756  return false;
757  }
758 
759  private static void intersectList(ArrayList A, ArrayList B, ArrayList result)
760  {
761  bool[] array = new bool[A.Count];
762  bool[] array2 = new bool[B.Count];
763  int num = 0;
764  foreach (object item in A)
765  {
766  int num2 = 0;
767  foreach (object item2 in B)
768  {
769  if (!array2[num2] && item.GetType() == item2.GetType())
770  {
771  if (item is Uri)
772  {
773  if (item.Equals(item2))
774  {
775  result.Add(item);
776  array[num] = (array2[num2] = true);
777  break;
778  }
779  }
780  else if (string.Compare(item.ToString(), item2.ToString(), StringComparison.OrdinalIgnoreCase) == 0)
781  {
782  result.Add(item);
783  array[num] = (array2[num2] = true);
784  break;
785  }
786  }
787  num2++;
788  }
789  num++;
790  }
791  num = 0;
792  foreach (object item3 in A)
793  {
794  if (!array[num])
795  {
796  int num2 = 0;
797  foreach (object item4 in B)
798  {
799  if (!array2[num2])
800  {
801  bool isUri;
802  object obj = intersectPair(item3, item4, out isUri);
803  if (obj != null)
804  {
805  bool flag = false;
806  foreach (object item5 in result)
807  {
808  if (isUri == item5 is Uri && (isUri ? obj.Equals(item5) : (string.Compare(item5.ToString(), obj.ToString(), StringComparison.OrdinalIgnoreCase) == 0)))
809  {
810  flag = true;
811  break;
812  }
813  }
814  if (!flag)
815  {
816  result.Add(obj);
817  }
818  }
819  }
820  num2++;
821  }
822  }
823  num++;
824  }
825  }
826 
827  private static object intersectPair(object L, object R, out bool isUri)
828  {
829  isUri = false;
830  DelayedRegex delayedRegex = L as DelayedRegex;
831  DelayedRegex delayedRegex2 = R as DelayedRegex;
832  if (delayedRegex != null && delayedRegex2 != null)
833  {
834  return new DelayedRegex("(?=(" + delayedRegex.ToString() + "))(" + delayedRegex2.ToString() + ")");
835  }
836  if (delayedRegex != null && delayedRegex2 == null)
837  {
838  isUri = (R is Uri);
839  string text = isUri ? ((Uri)R).GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped) : R.ToString();
840  Match match = delayedRegex.AsRegex.Match(text);
841  if (match != null && match.Index == 0 && match.Length == text.Length)
842  {
843  return R;
844  }
845  return null;
846  }
847  if (delayedRegex == null && delayedRegex2 != null)
848  {
849  isUri = (L is Uri);
850  string text2 = isUri ? ((Uri)L).GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped) : L.ToString();
851  Match match2 = delayedRegex2.AsRegex.Match(text2);
852  if (match2 != null && match2.Index == 0 && match2.Length == text2.Length)
853  {
854  return L;
855  }
856  return null;
857  }
858  isUri = (L is Uri);
859  if (isUri)
860  {
861  if (!L.Equals(R))
862  {
863  return null;
864  }
865  return L;
866  }
867  if (string.Compare(L.ToString(), R.ToString(), StringComparison.OrdinalIgnoreCase) != 0)
868  {
869  return null;
870  }
871  return L;
872  }
873  }
874 }
UriKind
Defines the kinds of T:System.Uris for the M:System.Uri.IsWellFormedUriString(System....
Definition: UriKind.cs:5
Allows a permission to expose an unrestricted state.
override void FromXml(SecurityElement securityElement)
Reconstructs a T:System.Net.WebPermission from an XML encoding.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
override IPermission Copy()
Creates a copy of a T:System.Net.WebPermission.
override string ToString()
Returns the regular expression pattern that was passed into the Regex constructor.
Definition: Regex.cs:415
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
NetworkAccess
Specifies network access permissions.
Definition: NetworkAccess.cs:5
WebPermission(NetworkAccess access, Regex uriRegex)
Initializes a new instance of the T:System.Net.WebPermission class with the specified access rights f...
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2255
Definition: __Canon.cs:3
SecurityElement SearchForChildByTag(string tag)
Finds a child by its tag name.
WebPermission(NetworkAccess access, string uriString)
Initializes a new instance of the T:System.Net.WebPermission class with the specified access rights f...
virtual void Clear()
Removes all elements from the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2461
virtual object Clone()
Creates a shallow copy of the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2473
string Tag
Gets or sets the tag name of an XML element.
static bool TryCreate(string uriString, UriKind uriKind, out Uri result)
Creates a new T:System.Uri using the specified T:System.String instance and a T:System....
Definition: Uri.cs:4782
UriComponents
Specifies the parts of a T:System.Uri.
Definition: UriComponents.cs:6
static string Escape(string str)
Replaces invalid XML characters in a string with their valid XML equivalent.
void AddChild(SecurityElement child)
Adds a child element to the XML element.
WebPermission(PermissionState state)
Creates a new instance of the T:System.Net.WebPermission class that passes all demands or fails all d...
WebPermission()
Creates a new instance of the T:System.Net.WebPermission class.
Represents the XML object model for encoding security objects. This class cannot be inherited.
int Index
The position in the original string where the first character of the captured substring is found.
Definition: Capture.cs:18
Controls rights to access HTTP Internet resources.
unsafe override bool Equals(object comparand)
Compares two T:System.Uri instances for equality.
Definition: Uri.cs:1731
Defines the underlying structure of all code access permissions.
string GetComponents(UriComponents components, UriFormat format)
Gets the specified components of the current instance using the specified escaping for special charac...
Definition: Uri.cs:4874
Defines methods implemented by permission types.
Definition: IPermission.cs:7
virtual int Add(object value)
Adds an object to the end of the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2381
override bool IsSubsetOf(IPermission target)
Determines whether the current T:System.Net.WebPermission is a subset of the specified object.
Represents the results from a single regular expression match.
Definition: Match.cs:8
void AddPermission(NetworkAccess access, string uriString)
Adds the specified URI string with the specified access rights to the current T:System....
The exception that is thrown when one of the arguments provided to a method is not valid.
static string Escape(string str)
Escapes a minimal set of characters (\, *, +, ?, |, {, [, (,), ^, $,., #, and white space) by replaci...
Definition: Regex.cs:386
Attribute can be applied to a module.
UriFormat
Controls how URI information is escaped.
Definition: UriFormat.cs:5
override SecurityElement ToXml()
Creates an XML encoding of a T:System.Net.WebPermission and its current state.
int Length
Gets the length of the captured substring.
Definition: Capture.cs:30
PermissionState
Specifies whether a permission should have all or no access to resources at creation.
IEnumerator?? ConnectList
This property returns an enumeration of a single connect permissions held by this T:System....
void AddAttribute(string name, string value)
Adds a name/value attribute to an XML element.
Specifies that the class can be serialized.
override IPermission Union(IPermission target)
Returns the logical union between two instances of the T:System.Net.WebPermission class.
ArrayList Children
Gets or sets the array of child elements of the XML element.
virtual IEnumerator GetEnumerator()
Returns an enumerator for the entire T:System.Collections.ArrayList.
Definition: ArrayList.cs:2615
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
override IPermission Intersect(IPermission target)
Returns the logical intersection of two T:System.Net.WebPermission instances.
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
Definition: Uri.cs:19
Represents an immutable regular expression.To browse the .NET Framework source code for this type,...
Definition: Regex.cs:16
Supports a simple iteration over a non-generic collection.
Definition: IEnumerator.cs:9
void AddPermission(NetworkAccess access, Regex uriRegex)
Adds the specified URI with the specified access rights to the current T:System.Net....
IEnumerator?? AcceptList
This property returns an enumeration of a single accept permissions held by this T:System....
bool IsUnrestricted()
Checks the overall permission state of the T:System.Net.WebPermission.
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
Definition: ArrayList.cs:14