// // MetadataTag.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 { /// /// A metadata tag. /// /// /// A metadata tag. /// public struct MetadataTag { /// /// A metadata tag for specifying the contact information for the server administrator. /// /// /// Used to get the contact information of the administrator on a /// . /// public static readonly MetadataTag SharedAdmin = new MetadataTag ("/shared/admin"); /// /// A metadata tag for private comments. /// /// /// Used to get or set a private comment on a . /// public static readonly MetadataTag PrivateComment = new MetadataTag ("/private/comment"); /// /// A metadata tag for shared comments. /// /// /// Used to get or set a shared comment on a /// or . /// public static readonly MetadataTag SharedComment = new MetadataTag ("/shared/comment"); /// /// A metadata tag for specifying the special use of a folder. /// /// /// Used to get or set the special use of a . /// public static readonly MetadataTag PrivateSpecialUse = new MetadataTag ("/private/specialuse"); /// /// Initializes a new instance of the struct. /// /// /// Creates a new . /// /// The metadata tag identifier. /// /// is null. /// /// /// is an empty string. /// public MetadataTag (string id) { if (id == null) throw new ArgumentNullException (nameof (id)); if (id.Length == 0) throw new ArgumentException ("A metadata tag identifier cannot be empty."); Id = id; } /// /// Get the metadata tag identifier. /// /// /// Gets the metadata tag identifier. /// /// The metadata tag identifier. public string Id { get; private set; } /// /// Determine 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 MetadataTag && ((MetadataTag) obj).Id == Id; } /// /// 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 Id.GetHashCode (); } /// /// Returns a that represents the current . /// /// /// Returns a that represents the current . /// /// A that represents the current . public override string ToString () { return Id; } internal static MetadataTag Create (string id) { switch (id) { case "/shared/admin": return SharedAdmin; case "/private/comment": return PrivateComment; case "/shared/comment": return SharedComment; case "/private/specialuse": return PrivateSpecialUse; default: return new MetadataTag (id); } } } }