using System; using System.Globalization; using System.Runtime.InteropServices; using System.Security.Permissions; using Mono.Security; namespace System.Security.Policy { /// Provides the URL from which a code assembly originates as evidence for policy evaluation. This class cannot be inherited. // Token: 0x020005A5 RID: 1445 [ComVisible(true)] [Serializable] public sealed class Url : IBuiltInEvidence, IIdentityPermissionFactory { /// Initializes a new instance of the class with the URL from which a code assembly originates. /// The URL of origin for the associated code assembly. /// The parameter is null. // Token: 0x060034E3 RID: 13539 RVA: 0x000B64AC File Offset: 0x000B46AC public Url(string name) : this(name, false) { } // Token: 0x060034E4 RID: 13540 RVA: 0x000B64B8 File Offset: 0x000B46B8 internal Url(string name, bool validated) { this.origin_url = ((!validated) ? this.Prepare(name) : name); } // Token: 0x060034E5 RID: 13541 RVA: 0x000B64DC File Offset: 0x000B46DC int IBuiltInEvidence.GetRequiredSize(bool verbose) { return ((!verbose) ? 1 : 3) + this.origin_url.Length; } // Token: 0x060034E6 RID: 13542 RVA: 0x000B64F8 File Offset: 0x000B46F8 [MonoTODO("IBuiltInEvidence")] int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position) { return 0; } // Token: 0x060034E7 RID: 13543 RVA: 0x000B64FC File Offset: 0x000B46FC [MonoTODO("IBuiltInEvidence")] int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose) { return 0; } /// Creates a new copy of the evidence object. /// A new, identical copy of the evidence object. // Token: 0x060034E8 RID: 13544 RVA: 0x000B6500 File Offset: 0x000B4700 public object Copy() { return new Url(this.origin_url, true); } /// Creates an identity permission corresponding to the current instance of the evidence class. /// A for the specified evidence. /// The evidence set from which to construct the identity permission. // Token: 0x060034E9 RID: 13545 RVA: 0x000B6510 File Offset: 0x000B4710 public IPermission CreateIdentityPermission(Evidence evidence) { return new UrlIdentityPermission(this.origin_url); } /// Compares the current evidence object to the specified object for equivalence. /// true if the two objects are equal; otherwise, false. /// The evidence object to test for equivalence with the current object. // Token: 0x060034EA RID: 13546 RVA: 0x000B6520 File Offset: 0x000B4720 public override bool Equals(object o) { Url url = o as Url; if (url == null) { return false; } string text = url.Value; string text2 = this.origin_url; if (text.IndexOf(Uri.SchemeDelimiter) < 0) { text = "file://" + text; } if (text2.IndexOf(Uri.SchemeDelimiter) < 0) { text2 = "file://" + text2; } return string.Compare(text, text2, true, CultureInfo.InvariantCulture) == 0; } /// Gets the hash code of the current URL. /// The hash code of the current URL. /// /// /// // Token: 0x060034EB RID: 13547 RVA: 0x000B6594 File Offset: 0x000B4794 public override int GetHashCode() { string text = this.origin_url; if (text.IndexOf(Uri.SchemeDelimiter) < 0) { text = "file://" + text; } return text.GetHashCode(); } /// Returns a string representation of the current . /// A representation of the current . // Token: 0x060034EC RID: 13548 RVA: 0x000B65CC File Offset: 0x000B47CC public override string ToString() { SecurityElement securityElement = new SecurityElement("System.Security.Policy.Url"); securityElement.AddAttribute("version", "1"); securityElement.AddChild(new SecurityElement("Url", this.origin_url)); return securityElement.ToString(); } /// Gets the URL from which the code assembly originates. /// The URL from which the code assembly originates. // Token: 0x17000A62 RID: 2658 // (get) Token: 0x060034ED RID: 13549 RVA: 0x000B6610 File Offset: 0x000B4810 public string Value { get { return this.origin_url; } } // Token: 0x060034EE RID: 13550 RVA: 0x000B6618 File Offset: 0x000B4818 private string Prepare(string url) { if (url == null) { throw new ArgumentNullException("Url"); } if (url == string.Empty) { throw new FormatException(Locale.GetText("Invalid (empty) Url")); } int num = url.IndexOf(Uri.SchemeDelimiter); if (num > 0) { if (url.StartsWith("file://")) { url = "file://" + url.Substring(7); } Uri uri = new Uri(url, false, false); url = uri.ToString(); } int num2 = url.Length - 1; if (url[num2] == '/') { url = url.Substring(0, num2); } return url; } // Token: 0x04001587 RID: 5511 private string origin_url; } }