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;
- using System.IO;
- using System.Security.Util;
- using System.Collections;
-
- [Serializable()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class ApplicationDirectory : IBuiltInEvidence
- {
- private URLString m_appDirectory;
-
- internal ApplicationDirectory()
- {
- m_appDirectory = null;
- }
-
- public ApplicationDirectory(string name)
- {
- if (name == null)
- throw new ArgumentNullException("name");
-
- m_appDirectory = new URLString(name);
- }
-
- public string Directory {
- get { return m_appDirectory.ToString(); }
- }
-
- public override bool Equals(object o)
- {
- if (o == null)
- return false;
-
- if (o is ApplicationDirectory) {
- ApplicationDirectory appDir = (ApplicationDirectory)o;
-
- if (this.m_appDirectory == null) {
- return appDir.m_appDirectory == null;
- }
- else if (appDir.m_appDirectory == null) {
- return false;
- }
- else {
- return this.m_appDirectory.IsSubsetOf(appDir.m_appDirectory) && appDir.m_appDirectory.IsSubsetOf(this.m_appDirectory);
- }
- }
- return false;
- }
-
- public override int GetHashCode()
- {
- return this.Directory.GetHashCode();
- }
-
- public object Copy()
- {
- ApplicationDirectory appDir = new ApplicationDirectory();
-
- appDir.m_appDirectory = this.m_appDirectory;
-
- return appDir;
- }
-
- internal SecurityElement ToXml()
- {
- SecurityElement root = new SecurityElement("System.Security.Policy.ApplicationDirectory");
-
-
- BCLDebug.Assert(this.GetType().FullName.Equals("System.Security.Policy.ApplicationDirectory"), "Class name changed!");
-
- root.AddAttribute("version", "1");
-
- if (m_appDirectory != null)
- root.AddChild(new SecurityElement("Directory", m_appDirectory.ToString()));
-
- return root;
- }
-
- /// <internalonly/>
- int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
- {
- buffer[position++] = BuiltInEvidenceHelper.idApplicationDirectory;
- string directory = this.Directory;
- int length = directory.Length;
-
- if (verbose) {
- BuiltInEvidenceHelper.CopyIntToCharArray(length, buffer, position);
- position += 2;
- }
- directory.CopyTo(0, buffer, position, length);
- return length + position;
- }
-
- /// <internalonly/>
- int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
- {
- int length = BuiltInEvidenceHelper.GetIntFromCharArray(buffer, position);
- position += 2;
-
- m_appDirectory = new URLString(new string(buffer, position, length));
-
- return position + length;
- }
-
- /// <internalonly/>
- int IBuiltInEvidence.GetRequiredSize(bool verbose)
- {
- if (verbose)
- return this.Directory.Length + 3;
- else
-
- return this.Directory.Length + 1;
-
- }
-
- public override string ToString()
- {
- return ToXml().ToString();
- }
- }
- }