-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPrivilegeAndAttributes.cs
More file actions
97 lines (85 loc) · 3.66 KB
/
PrivilegeAndAttributes.cs
File metadata and controls
97 lines (85 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// <copyright file="PrivilegeAndAttributes.cs" company="Nick Lowe">
// Copyright © Nick Lowe 2009
// </copyright>
// <author>Nick Lowe</author>
// <email>nick@int-r.net</email>
// <url>http://processprivileges.codeplex.com/</url>
namespace ProcessPrivileges
{
using System;
/// <summary>Structure that links <see cref="Privilege"/> and <see cref="PrivilegeAttributes"/> together.</summary>
public struct PrivilegeAndAttributes : IEquatable<PrivilegeAndAttributes>
{
private readonly Privilege privilege;
private readonly PrivilegeAttributes privilegeAttributes;
internal PrivilegeAndAttributes(Privilege privilege, PrivilegeAttributes privilegeAttributes)
{
this.privilege = privilege;
this.privilegeAttributes = privilegeAttributes;
}
/// <summary>Gets the privilege.</summary>
/// <value>The privilege.</value>
public Privilege Privilege
{
get
{
return this.privilege;
}
}
/// <summary>Gets the privilege attributes.</summary>
/// <value>The privilege attributes.</value>
public PrivilegeAttributes PrivilegeAttributes
{
get
{
return this.privilegeAttributes;
}
}
/// <summary>Gets the privilege state.</summary>
/// <value>The privilege state.</value>
/// <remarks>Derived from <see cref="PrivilegeAttributes"/>.</remarks>
public PrivilegeState PrivilegeState
{
get
{
return ProcessExtensions.GetPrivilegeState(this.privilegeAttributes);
}
}
/// <summary>Compares two instances for equality.</summary>
/// <param name="first">First instance.</param>
/// <param name="second">Second instance.</param>
/// <returns>Value indicating equality of instances.</returns>
public static bool operator ==(PrivilegeAndAttributes first, PrivilegeAndAttributes second)
{
return first.Equals(second);
}
/// <summary>Compares two instances for inequality.</summary>
/// <param name="first">First instance.</param>
/// <param name="second">Second instance.</param>
/// <returns>Value indicating inequality of instances.</returns>
public static bool operator !=(PrivilegeAndAttributes first, PrivilegeAndAttributes second)
{
return !first.Equals(second);
}
/// <summary>Returns the hash code for this instance.</summary>
/// <returns>The hash code for this instance.</returns>
public override int GetHashCode()
{
return this.privilege.GetHashCode() ^ this.privilegeAttributes.GetHashCode();
}
/// <summary>Indicates whether this instance and a specified object are equal.</summary>
/// <param name="obj">Another object to compare to.</param>
/// <returns>Value indicating whether this instance and a specified object are equal.</returns>
public override bool Equals(object obj)
{
return obj is PrivilegeAttributes ? this.Equals((PrivilegeAttributes)obj) : false;
}
/// <summary>Indicates whether this instance and another instance are equal.</summary>
/// <param name="other">Another instance to compare to.</param>
/// <returns>Value indicating whether this instance and another instance are equal.</returns>
public bool Equals(PrivilegeAndAttributes other)
{
return this.privilege == other.Privilege && this.privilegeAttributes == other.PrivilegeAttributes;
}
}
}