// // Copyright © Nick Lowe 2009 // // Nick Lowe // nick@int-r.net // http://processprivileges.codeplex.com/ namespace ProcessPrivileges { using System; /// Structure that links and together. public struct PrivilegeAndAttributes : IEquatable { private readonly Privilege privilege; private readonly PrivilegeAttributes privilegeAttributes; internal PrivilegeAndAttributes(Privilege privilege, PrivilegeAttributes privilegeAttributes) { this.privilege = privilege; this.privilegeAttributes = privilegeAttributes; } /// Gets the privilege. /// The privilege. public Privilege Privilege { get { return this.privilege; } } /// Gets the privilege attributes. /// The privilege attributes. public PrivilegeAttributes PrivilegeAttributes { get { return this.privilegeAttributes; } } /// Gets the privilege state. /// The privilege state. /// Derived from . public PrivilegeState PrivilegeState { get { return ProcessExtensions.GetPrivilegeState(this.privilegeAttributes); } } /// Compares two instances for equality. /// First instance. /// Second instance. /// Value indicating equality of instances. public static bool operator ==(PrivilegeAndAttributes first, PrivilegeAndAttributes second) { return first.Equals(second); } /// Compares two instances for inequality. /// First instance. /// Second instance. /// Value indicating inequality of instances. public static bool operator !=(PrivilegeAndAttributes first, PrivilegeAndAttributes second) { return !first.Equals(second); } /// Returns the hash code for this instance. /// The hash code for this instance. public override int GetHashCode() { return this.privilege.GetHashCode() ^ this.privilegeAttributes.GetHashCode(); } /// Indicates whether this instance and a specified object are equal. /// Another object to compare to. /// Value indicating whether this instance and a specified object are equal. public override bool Equals(object obj) { return obj is PrivilegeAttributes ? this.Equals((PrivilegeAttributes)obj) : false; } /// Indicates whether this instance and another instance are equal. /// Another instance to compare to. /// Value indicating whether this instance and another instance are equal. public bool Equals(PrivilegeAndAttributes other) { return this.privilege == other.Privilege && this.privilegeAttributes == other.PrivilegeAttributes; } public override string ToString() { return privilege.ToString(); } } }