// // AccessRight.cs // // Author: Jeffrey Stedfast // // Copyright (c) 2013-2020 .NET Foundation and Contributors // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // using System; namespace MailKit { /// /// An individual Access Right to be used with ACLs. /// /// /// An individual Access Right meant to be used with /// . /// For more information on what rights are available, /// see https://tools.ietf.org/html/rfc4314#section-2.1 /// /// public struct AccessRight : IEquatable { /// /// The access right for folder lookups. /// /// /// Allows the to be visible when listing folders. /// public static readonly AccessRight LookupFolder = new AccessRight ('l'); /// /// The access right for opening a folder and getting the status. /// /// /// Provides access for opening and getting the status of the folder. /// public static readonly AccessRight OpenFolder = new AccessRight ('r'); /// /// The access right for adding or removing the Seen flag on messages in the folder. /// /// /// Provides access to add or remove the flag on messages within the /// . /// public static readonly AccessRight SetMessageSeen = new AccessRight ('s'); /// /// The access right for adding or removing flags (other than Seen and Deleted) /// on messages in a folder. /// /// /// Provides access to add or remove the on messages /// (other than and /// ) within the folder. /// public static readonly AccessRight SetMessageFlags = new AccessRight ('w'); /// /// The access right allowing messages to be appended or copied into the folder. /// /// /// Provides access to append or copy messages into the folder. /// public static readonly AccessRight AppendMessages = new AccessRight ('i'); /// /// The access right allowing subfolders to be created. /// /// /// Provides access to create subfolders. /// public static readonly AccessRight CreateFolder = new AccessRight ('k'); /// /// The access right for deleting a folder and/or its subfolders. /// /// /// Provides access to delete the folder and/or any subfolders. /// public static readonly AccessRight DeleteFolder = new AccessRight ('x'); /// /// The access right for adding or removing the Deleted flag to messages within a folder. /// /// /// Provides access to add or remove the flag from /// messages within the folder. It also provides access for setting the /// flag when appending a message to a folder. /// public static readonly AccessRight SetMessageDeleted = new AccessRight ('t'); /// /// The access right for expunging deleted messages in a folder. /// /// /// Provides access to expunge deleted messages in a folder. /// public static readonly AccessRight ExpungeFolder = new AccessRight ('e'); /// /// The access right for administering the ACLs of a folder. /// /// /// Provides administrative access to change the ACLs for the folder. /// public static readonly AccessRight Administer = new AccessRight ('a'); /// /// The character representing the particular access right. /// /// /// Represents the character value of the access right. /// public readonly char Right; /// /// Initializes a new instance of the struct. /// /// /// Creates a new struct. /// /// The access right. public AccessRight (char right) { Right = right; } #region IEquatable implementation /// /// Determines whether the specified is equal to the current . /// /// /// Determines whether the specified is equal to the current . /// /// The to compare with the current . /// true if the specified is equal to the current /// ; otherwise, false. public bool Equals (AccessRight other) { return other.Right == Right; } #endregion /// /// Determines whether two access rights are equal. /// /// /// Determines whether two access rights are equal. /// /// true if and are equal; otherwise, false. /// The first access right to compare. /// The second access right to compare. public static bool operator == (AccessRight right1, AccessRight right2) { return right1.Right == right2.Right; } /// /// Determines whether two access rights are not equal. /// /// /// Determines whether two access rights are not equal. /// /// true if and are not equal; otherwise, false. /// The first access right to compare. /// The second access right to compare. public static bool operator != (AccessRight right1, AccessRight right2) { return right1.Right != right2.Right; } /// /// Determines whether the specified is equal to the current . /// /// /// Determines whether the specified is equal to the current . /// /// The to compare with the current . /// true if the specified is equal to the current ; /// otherwise, false. public override bool Equals (object obj) { return obj is AccessRight && ((AccessRight) obj).Right == Right; } /// /// Serves as a hash function for a object. /// /// /// Serves as a hash function for a object. /// /// A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a hash table. public override int GetHashCode () { return Right.GetHashCode (); } /// /// Returns a that represents the current . /// /// /// Returns a that represents the current . /// /// A that represents the current . public override string ToString () { return Right.ToString (); } } }