119 lines
4.3 KiB
C#
119 lines
4.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace System.Security.Policy
|
|
{
|
|
/// <summary>Provides the application directory as evidence for policy evaluation. This class cannot be inherited.</summary>
|
|
// Token: 0x0200057A RID: 1402
|
|
[ComVisible(true)]
|
|
[Serializable]
|
|
public sealed class ApplicationDirectory : IBuiltInEvidence
|
|
{
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.ApplicationDirectory" /> class.</summary>
|
|
/// <param name="name">The path of the application directory. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">The <paramref name="name" /> parameter is null. </exception>
|
|
// Token: 0x0600333C RID: 13116 RVA: 0x000B03E0 File Offset: 0x000AE5E0
|
|
public ApplicationDirectory(string name)
|
|
{
|
|
if (name == null)
|
|
{
|
|
throw new ArgumentNullException("name");
|
|
}
|
|
if (name.Length < 1)
|
|
{
|
|
throw new FormatException(Locale.GetText("Empty"));
|
|
}
|
|
this.directory = name;
|
|
}
|
|
|
|
// Token: 0x0600333D RID: 13117 RVA: 0x000B0428 File Offset: 0x000AE628
|
|
int IBuiltInEvidence.GetRequiredSize(bool verbose)
|
|
{
|
|
return ((!verbose) ? 1 : 3) + this.directory.Length;
|
|
}
|
|
|
|
// Token: 0x0600333E RID: 13118 RVA: 0x000B0444 File Offset: 0x000AE644
|
|
[MonoTODO("IBuiltInEvidence")]
|
|
int IBuiltInEvidence.InitFromBuffer(char[] buffer, int position)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
// Token: 0x0600333F RID: 13119 RVA: 0x000B0448 File Offset: 0x000AE648
|
|
[MonoTODO("IBuiltInEvidence")]
|
|
int IBuiltInEvidence.OutputToBuffer(char[] buffer, int position, bool verbose)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>Gets the path of the application directory.</summary>
|
|
/// <returns>The path of the application directory.</returns>
|
|
// Token: 0x17000A0E RID: 2574
|
|
// (get) Token: 0x06003340 RID: 13120 RVA: 0x000B044C File Offset: 0x000AE64C
|
|
public string Directory
|
|
{
|
|
get
|
|
{
|
|
return this.directory;
|
|
}
|
|
}
|
|
|
|
/// <summary>Creates a new copy of the <see cref="T:System.Security.Policy.ApplicationDirectory" />.</summary>
|
|
/// <returns>A new, identical copy of the <see cref="T:System.Security.Policy.ApplicationDirectory" />.</returns>
|
|
// Token: 0x06003341 RID: 13121 RVA: 0x000B0454 File Offset: 0x000AE654
|
|
public object Copy()
|
|
{
|
|
return new ApplicationDirectory(this.Directory);
|
|
}
|
|
|
|
/// <summary>Determines whether instances of the same type of an evidence object are equivalent.</summary>
|
|
/// <returns>true if the two instances are equivalent; otherwise, false.</returns>
|
|
/// <param name="o">An object of same type as the current evidence object. </param>
|
|
// Token: 0x06003342 RID: 13122 RVA: 0x000B0464 File Offset: 0x000AE664
|
|
public override bool Equals(object o)
|
|
{
|
|
ApplicationDirectory applicationDirectory = o as ApplicationDirectory;
|
|
if (applicationDirectory != null)
|
|
{
|
|
this.ThrowOnInvalid(applicationDirectory.directory);
|
|
return this.directory == applicationDirectory.directory;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/// <summary>Gets the hash code of the current application directory.</summary>
|
|
/// <returns>The hash code of the current application directory.</returns>
|
|
// Token: 0x06003343 RID: 13123 RVA: 0x000B04A0 File Offset: 0x000AE6A0
|
|
public override int GetHashCode()
|
|
{
|
|
return this.Directory.GetHashCode();
|
|
}
|
|
|
|
/// <summary>Gets a string representation of the state of the <see cref="T:System.Security.Policy.ApplicationDirectory" /> evidence object.</summary>
|
|
/// <returns>A representation of the state of the <see cref="T:System.Security.Policy.ApplicationDirectory" /> evidence object.</returns>
|
|
// Token: 0x06003344 RID: 13124 RVA: 0x000B04B0 File Offset: 0x000AE6B0
|
|
public override string ToString()
|
|
{
|
|
this.ThrowOnInvalid(this.Directory);
|
|
SecurityElement securityElement = new SecurityElement("System.Security.Policy.ApplicationDirectory");
|
|
securityElement.AddAttribute("version", "1");
|
|
securityElement.AddChild(new SecurityElement("Directory", this.directory));
|
|
return securityElement.ToString();
|
|
}
|
|
|
|
// Token: 0x06003345 RID: 13125 RVA: 0x000B0500 File Offset: 0x000AE700
|
|
private void ThrowOnInvalid(string appdir)
|
|
{
|
|
if (appdir.IndexOfAny(Path.InvalidPathChars) != -1)
|
|
{
|
|
string text = Locale.GetText("Invalid character(s) in directory {0}");
|
|
throw new ArgumentException(string.Format(text, appdir), "other");
|
|
}
|
|
}
|
|
|
|
// Token: 0x04001502 RID: 5378
|
|
private string directory;
|
|
}
|
|
}
|