using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace System.Security.Policy
{
/// Represents the statement of a describing the permissions and other information that apply to code with a particular set of evidence. This class cannot be inherited.
// Token: 0x0200059A RID: 1434
[ComVisible(true)]
[Serializable]
public sealed class PolicyStatement : ISecurityEncodable, ISecurityPolicyEncodable
{
/// Initializes a new instance of the class with the specified .
/// The with which to initialize the new instance.
// Token: 0x06003470 RID: 13424 RVA: 0x000B50DC File Offset: 0x000B32DC
public PolicyStatement(PermissionSet permSet)
: this(permSet, PolicyStatementAttribute.Nothing)
{
}
/// Initializes a new instance of the class with the specified and attributes.
/// The with which to initialize the new instance.
/// A bitwise combination of the values.
// Token: 0x06003471 RID: 13425 RVA: 0x000B50E8 File Offset: 0x000B32E8
public PolicyStatement(PermissionSet permSet, PolicyStatementAttribute attributes)
{
if (permSet != null)
{
this.perms = permSet.Copy();
this.perms.SetReadOnly(true);
}
this.attrs = attributes;
}
/// Gets or sets the of the policy statement.
/// The of the policy statement.
// Token: 0x17000A4E RID: 2638
// (get) Token: 0x06003472 RID: 13426 RVA: 0x000B5120 File Offset: 0x000B3320
// (set) Token: 0x06003473 RID: 13427 RVA: 0x000B514C File Offset: 0x000B334C
public PermissionSet PermissionSet
{
get
{
if (this.perms == null)
{
this.perms = new PermissionSet(PermissionState.None);
this.perms.SetReadOnly(true);
}
return this.perms;
}
set
{
this.perms = value;
}
}
/// Gets or sets the attributes of the policy statement.
/// The attributes of the policy statement.
// Token: 0x17000A4F RID: 2639
// (get) Token: 0x06003474 RID: 13428 RVA: 0x000B5158 File Offset: 0x000B3358
// (set) Token: 0x06003475 RID: 13429 RVA: 0x000B5160 File Offset: 0x000B3360
public PolicyStatementAttribute Attributes
{
get
{
return this.attrs;
}
set
{
switch (value)
{
case PolicyStatementAttribute.Nothing:
case PolicyStatementAttribute.Exclusive:
case PolicyStatementAttribute.LevelFinal:
case PolicyStatementAttribute.All:
this.attrs = value;
return;
default:
{
string text = Locale.GetText("Invalid value for {0}.");
throw new ArgumentException(string.Format(text, "PolicyStatementAttribute"));
}
}
}
}
/// Gets a string representation of the attributes of the policy statement.
/// A text string representing the attributes of the policy statement.
// Token: 0x17000A50 RID: 2640
// (get) Token: 0x06003476 RID: 13430 RVA: 0x000B51B4 File Offset: 0x000B33B4
public string AttributeString
{
get
{
switch (this.attrs)
{
case PolicyStatementAttribute.Exclusive:
return "Exclusive";
case PolicyStatementAttribute.LevelFinal:
return "LevelFinal";
case PolicyStatementAttribute.All:
return "Exclusive LevelFinal";
default:
return string.Empty;
}
}
}
/// Creates an equivalent copy of the current policy statement.
/// A new copy of the with and identical to those of the current .
// Token: 0x06003477 RID: 13431 RVA: 0x000B51F8 File Offset: 0x000B33F8
public PolicyStatement Copy()
{
return new PolicyStatement(this.perms, this.attrs);
}
/// Reconstructs a security object with a given state from an XML encoding.
/// The XML encoding to use to reconstruct the security object.
/// The parameter is null.
/// The parameter is not a valid encoding.
///
///
///
// Token: 0x06003478 RID: 13432 RVA: 0x000B520C File Offset: 0x000B340C
public void FromXml(SecurityElement et)
{
this.FromXml(et, null);
}
/// Reconstructs a security object with a given state from an XML encoding.
/// The XML encoding to use to reconstruct the security object.
/// The context for lookup of values.
/// The parameter is null.
/// The parameter is not a valid encoding.
///
///
///
// Token: 0x06003479 RID: 13433 RVA: 0x000B5218 File Offset: 0x000B3418
public void FromXml(SecurityElement et, PolicyLevel level)
{
if (et == null)
{
throw new ArgumentNullException("et");
}
if (et.Tag != "PolicyStatement")
{
throw new ArgumentException(Locale.GetText("Invalid tag."));
}
string text = et.Attribute("Attributes");
if (text != null)
{
this.attrs = (PolicyStatementAttribute)((int)Enum.Parse(typeof(PolicyStatementAttribute), text));
}
SecurityElement securityElement = et.SearchForChildByTag("PermissionSet");
this.PermissionSet.FromXml(securityElement);
}
/// Creates an XML encoding of the security object and its current state.
/// An XML encoding of the security object, including any state information.
///
///
///
// Token: 0x0600347A RID: 13434 RVA: 0x000B52A0 File Offset: 0x000B34A0
public SecurityElement ToXml()
{
return this.ToXml(null);
}
/// Creates an XML encoding of the security object and its current state.
/// An XML encoding of the security object, including any state information.
/// The context for lookup of values.
///
///
///
// Token: 0x0600347B RID: 13435 RVA: 0x000B52AC File Offset: 0x000B34AC
public SecurityElement ToXml(PolicyLevel level)
{
SecurityElement securityElement = new SecurityElement("PolicyStatement");
securityElement.AddAttribute("version", "1");
if (this.attrs != PolicyStatementAttribute.Nothing)
{
securityElement.AddAttribute("Attributes", this.attrs.ToString());
}
securityElement.AddChild(this.PermissionSet.ToXml());
return securityElement;
}
/// Determines whether the specified object is equal to the current .
/// true if the specified is equal to the current object; otherwise, false.
/// The object to compare with the current .
// Token: 0x0600347C RID: 13436 RVA: 0x000B530C File Offset: 0x000B350C
[ComVisible(false)]
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
PolicyStatement policyStatement = obj as PolicyStatement;
return policyStatement != null && this.PermissionSet.Equals(obj) && this.attrs == policyStatement.attrs;
}
/// Gets a hash code for the object that is suitable for use in hashing algorithms and data structures such as a hash table.
/// A hash code for the current object.
///
///
///
// Token: 0x0600347D RID: 13437 RVA: 0x000B5354 File Offset: 0x000B3554
[ComVisible(false)]
public override int GetHashCode()
{
return this.PermissionSet.GetHashCode() ^ (int)this.attrs;
}
// Token: 0x0600347E RID: 13438 RVA: 0x000B5368 File Offset: 0x000B3568
internal static PolicyStatement Empty()
{
return new PolicyStatement(new PermissionSet(PermissionState.None));
}
// Token: 0x04001569 RID: 5481
private PermissionSet perms;
// Token: 0x0400156A RID: 5482
private PolicyStatementAttribute attrs;
}
}