We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
- namespace System.Security.Policy
- {
- using System.IO;
- using System.Security.Util;
- using UrlIdentityPermission = System.Security.Permissions.UrlIdentityPermission;
- using System.Runtime.Serialization;
-
- [Serializable()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class Url : IIdentityPermissionFactory, IBuiltInEvidence
- {
- private URLString m_url;
-
- internal Url()
- {
- m_url = null;
- }
-
- internal Url(SerializationInfo info, StreamingContext context)
- {
- m_url = new URLString((string)info.GetValue("Url", typeof(string)));
- }
-
- internal Url(string name, bool parsed)
- {
- if (name == null)
- throw new ArgumentNullException("name");
-
- m_url = new URLString(name, parsed);
- }
-
- public Url(string name)
- {
- if (name == null)
- throw new ArgumentNullException("name");
-
- m_url = new URLString(name);
- }
-
- public string Value {
- get {
- if (m_url == null)
- return null;
- return m_url.ToString();
- }
- }
-
- internal URLString GetURLString()
- {
- return m_url;
- }
-
- public IPermission CreateIdentityPermission(Evidence evidence)
- {
- return new UrlIdentityPermission(m_url);
- }
-
- public override bool Equals(object o)
- {
- if (o == null)
- return false;
-
- if (o is Url) {
- Url url = (Url)o;
-
- if (this.m_url == null) {
- return url.m_url == null;
- }
- else if (url.m_url == null) {
- return false;
- }
- else {
- return this.m_url.Equals(url.m_url);
- }
- }
- return false;
- }
-
- public override int GetHashCode()
- {
- if (this.m_url == null)
- return 0;
- else
- return this.m_url.GetHashCode();
- }
-
- public object Copy()
- {
- Url url = new Url();
-
- url.m_url = this.m_url;
-
- return url;
- }
-
- internal SecurityElement ToXml()
- {
- SecurityElement root = new SecurityElement("System.Security.Policy.Url");
-
-
- BCLDebug.Assert(this.GetType().FullName.Equals("System.Security.Policy.Url"), "Class name changed!");
-
- root.AddAttribute("version", "1");
-
- if (m_url != null)
- root.AddChild(new SecurityElement("Url", m_url.ToString()));
-
- return root;
- }
-
- public override string ToString()
- {
- return ToXml().ToString();
- }
-
- /// <internalonly/>
- int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
- {
- buffer[position++] = BuiltInEvidenceHelper.idUrl;
- string value = this.Value;
- int length = value.Length;
- if (verbose) {
- BuiltInEvidenceHelper.CopyIntToCharArray(length, buffer, position);
- position += 2;
- }
-
- value.CopyTo(0, buffer, position, length);
- return length + position;
- }
-
- /// <internalonly/>
- int IBuiltInEvidence.GetRequiredSize(bool verbose)
- {
- if (verbose)
- return this.Value.Length + 3;
- else
- return this.Value.Length + 1;
- }
-
- /// <internalonly/>
- int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
- {
- int length = BuiltInEvidenceHelper.GetIntFromCharArray(buffer, position);
- position += 2;
-
- m_url = new URLString(new string(buffer, position, length));
-
- return position + length;
- }
-
-
-
-
- internal object Normalize()
- {
- return m_url.NormalizeUrl();
- }
- }
- }