IDRole
namespace System.Security.Permissions
{
internal sealed class IDRole
{
internal bool Authenticated { get; }
internal string ID { get; }
internal string Role { get; }
internal IDRole(bool authenticated, string id, string role)
{
Authenticated = authenticated;
ID = id;
Role = role;
}
internal IDRole(SecurityElement e)
{
string text = e.Attribute("Authenticated");
Authenticated = (text != null && string.Equals(text, "true", StringComparison.OrdinalIgnoreCase));
ID = e.Attribute("ID");
Role = e.Attribute("Role");
}
internal SecurityElement ToXml()
{
SecurityElement securityElement = new SecurityElement("Identity");
if (Authenticated)
securityElement.AddAttribute("Authenticated", "true");
if (ID != null)
securityElement.AddAttribute("ID", SecurityElement.Escape(ID));
if (Role != null)
securityElement.AddAttribute("Role", SecurityElement.Escape(Role));
return securityElement;
}
public override int GetHashCode()
{
return ((!Authenticated) ? 101 : 0) + ((ID != null) ? ID.GetHashCode() : 0) + ((Role != null) ? Role.GetHashCode() : 0);
}
}
}