move source into dll

master
Christopher 2020-06-30 09:54:27 +02:00
parent 163124945e
commit 74070dc6b1
438 changed files with 28 additions and 211295 deletions

BIN
BouncyCastle.Crypto.dll Normal file

Binary file not shown.

BIN
MailKit.dll Normal file

Binary file not shown.

BIN
MimeKit.dll Normal file

Binary file not shown.

View File

@ -30,6 +30,10 @@
<Reference name="OpenSim.Services.Interfaces" path="../../../bin"/>
<Reference name="OpenSim.Server.Base" path="../../../bin"/>
<Reference name="OpenSim.Data" path="../../../bin"/>
<Reference name="BouncyCastle.Crypto.dll" path="../"/>
<Reference name="MailKit.dll" path="../"/>
<Reference name="MimeKit.dll" path="../"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>

View File

@ -1,137 +0,0 @@
//
// AccessControl.cs
//
// Author: Jeffrey Stedfast <jestedfa@microsoft.com>
//
// 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;
using System.Collections.Generic;
namespace MailKit {
/// <summary>
/// An Access Control.
/// </summary>
/// <remarks>
/// An Access Control is a set of permissions available for a particular identity,
/// controlling whether or not that identity has the ability to perform various tasks.
/// </remarks>
/// <example>
/// <code language="c#" source="Examples\ImapExamples.cs" region="Capabilities"/>
/// </example>
public class AccessControl
{
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AccessControl"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="MailKit.AccessControl"/> with the given name and
/// access rights.
/// </remarks>
/// <param name="name">The identifier name.</param>
/// <param name="rights">The access rights.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="name"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="rights"/> is <c>null</c>.</para>
/// </exception>
public AccessControl (string name, IEnumerable<AccessRight> rights)
{
if (name == null)
throw new ArgumentNullException (nameof (name));
Rights = new AccessRights (rights);
Name = name;
}
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AccessControl"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="MailKit.AccessControl"/> with the given name and
/// access rights.
/// </remarks>
/// <param name="name">The identifier name.</param>
/// <param name="rights">The access rights.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="name"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="rights"/> is <c>null</c>.</para>
/// </exception>
public AccessControl (string name, string rights)
{
if (name == null)
throw new ArgumentNullException (nameof (name));
Rights = new AccessRights (rights);
Name = name;
}
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AccessControl"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="MailKit.AccessControl"/> with the given name and no
/// access rights.
/// </remarks>
/// <param name="name">The identifier name.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="name"/> is <c>null</c>.
/// </exception>
public AccessControl (string name)
{
if (name == null)
throw new ArgumentNullException (nameof (name));
Rights = new AccessRights ();
Name = name;
}
/// <summary>
/// The identifier name for the access control.
/// </summary>
/// <remarks>
/// The identifier name for the access control.
/// </remarks>
/// <example>
/// <code language="c#" source="Examples\ImapExamples.cs" region="Capabilities"/>
/// </example>
/// <value>The identifier name.</value>
public string Name {
get; private set;
}
/// <summary>
/// Get the access rights.
/// </summary>
/// <remarks>
/// Gets the access rights.
/// </remarks>
/// <example>
/// <code language="c#" source="Examples\ImapExamples.cs" region="Capabilities"/>
/// </example>
/// <value>The access rights.</value>
public AccessRights Rights {
get; private set;
}
}
}

View File

@ -1,66 +0,0 @@
//
// AccessControlList.cs
//
// Author: Jeffrey Stedfast <jestedfa@microsoft.com>
//
// 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.Collections.Generic;
namespace MailKit {
/// <summary>
/// An Access Control List (ACL)
/// </summary>
/// <remarks>
/// An Access Control List (ACL) is a list of access controls defining the permissions
/// various identities have available.
/// </remarks>
/// <example>
/// <code language="c#" source="Examples\ImapExamples.cs" region="Capabilities"/>
/// </example>
public class AccessControlList : List<AccessControl>
{
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AccessControlList"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="MailKit.AccessControlList"/>.
/// </remarks>
/// <param name="controls">The list of access controls.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="controls"/> is <c>null</c>.
/// </exception>
public AccessControlList (IEnumerable<AccessControl> controls) : base (controls)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AccessControlList"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="MailKit.AccessControlList"/>.
/// </remarks>
public AccessControlList ()
{
}
}
}

View File

@ -1,232 +0,0 @@
//
// AccessRight.cs
//
// Author: Jeffrey Stedfast <jestedfa@microsoft.com>
//
// 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 {
/// <summary>
/// An individual Access Right to be used with ACLs.
/// </summary>
/// <remarks>
/// <para>An individual Access Right meant to be used with
/// <see cref="AccessControlList"/>.</para>
/// <para>For more information on what rights are available,
/// see https://tools.ietf.org/html/rfc4314#section-2.1
/// </para>
/// </remarks>
public struct AccessRight : IEquatable<AccessRight>
{
/// <summary>
/// The access right for folder lookups.
/// </summary>
/// <remarks>
/// Allows the <see cref="MailKit.IMailFolder"/> to be visible when listing folders.
/// </remarks>
public static readonly AccessRight LookupFolder = new AccessRight ('l');
/// <summary>
/// The access right for opening a folder and getting the status.
/// </summary>
/// <remarks>
/// Provides access for opening and getting the status of the folder.
/// </remarks>
public static readonly AccessRight OpenFolder = new AccessRight ('r');
/// <summary>
/// The access right for adding or removing the Seen flag on messages in the folder.
/// </summary>
/// <remarks>
/// Provides access to add or remove the <see cref="MessageFlags.Seen"/> flag on messages within the
/// <see cref="MailKit.IMailFolder"/>.
/// </remarks>
public static readonly AccessRight SetMessageSeen = new AccessRight ('s');
/// <summary>
/// The access right for adding or removing flags (other than Seen and Deleted)
/// on messages in a folder.
/// </summary>
/// <remarks>
/// Provides access to add or remove the <see cref="MessageFlags"/> on messages
/// (other than <see cref="MessageFlags.Seen"/> and
/// <see cref="MessageFlags.Deleted"/>) within the folder.
/// </remarks>
public static readonly AccessRight SetMessageFlags = new AccessRight ('w');
/// <summary>
/// The access right allowing messages to be appended or copied into the folder.
/// </summary>
/// <remarks>
/// Provides access to append or copy messages into the folder.
/// </remarks>
public static readonly AccessRight AppendMessages = new AccessRight ('i');
/// <summary>
/// The access right allowing subfolders to be created.
/// </summary>
/// <remarks>
/// Provides access to create subfolders.
/// </remarks>
public static readonly AccessRight CreateFolder = new AccessRight ('k');
/// <summary>
/// The access right for deleting a folder and/or its subfolders.
/// </summary>
/// <remarks>
/// Provides access to delete the folder and/or any subfolders.
/// </remarks>
public static readonly AccessRight DeleteFolder = new AccessRight ('x');
/// <summary>
/// The access right for adding or removing the Deleted flag to messages within a folder.
/// </summary>
/// <remarks>
/// Provides access to add or remove the <see cref="MessageFlags.Deleted"/> flag from
/// messages within the folder. It also provides access for setting the
/// <see cref="MessageFlags.Deleted"/> flag when appending a message to a folder.
/// </remarks>
public static readonly AccessRight SetMessageDeleted = new AccessRight ('t');
/// <summary>
/// The access right for expunging deleted messages in a folder.
/// </summary>
/// <remarks>
/// Provides access to expunge deleted messages in a folder.
/// </remarks>
public static readonly AccessRight ExpungeFolder = new AccessRight ('e');
/// <summary>
/// The access right for administering the ACLs of a folder.
/// </summary>
/// <remarks>
/// Provides administrative access to change the ACLs for the folder.
/// </remarks>
public static readonly AccessRight Administer = new AccessRight ('a');
/// <summary>
/// The character representing the particular access right.
/// </summary>
/// <remarks>
/// Represents the character value of the access right.
/// </remarks>
public readonly char Right;
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AccessRight"/> struct.
/// </summary>
/// <remarks>
/// Creates a new <see cref="MailKit.AccessRight"/> struct.
/// </remarks>
/// <param name="right">The access right.</param>
public AccessRight (char right)
{
Right = right;
}
#region IEquatable implementation
/// <summary>
/// Determines whether the specified <see cref="MailKit.AccessRight"/> is equal to the current <see cref="MailKit.AccessRight"/>.
/// </summary>
/// <remarks>
/// Determines whether the specified <see cref="MailKit.AccessRight"/> is equal to the current <see cref="MailKit.AccessRight"/>.
/// </remarks>
/// <param name="other">The <see cref="MailKit.AccessRight"/> to compare with the current <see cref="MailKit.AccessRight"/>.</param>
/// <returns><c>true</c> if the specified <see cref="MailKit.AccessRight"/> is equal to the current
/// <see cref="MailKit.AccessRight"/>; otherwise, <c>false</c>.</returns>
public bool Equals (AccessRight other)
{
return other.Right == Right;
}
#endregion
/// <summary>
/// Determines whether two access rights are equal.
/// </summary>
/// <remarks>
/// Determines whether two access rights are equal.
/// </remarks>
/// <returns><c>true</c> if <paramref name="right1"/> and <paramref name="right2"/> are equal; otherwise, <c>false</c>.</returns>
/// <param name="right1">The first access right to compare.</param>
/// <param name="right2">The second access right to compare.</param>
public static bool operator == (AccessRight right1, AccessRight right2)
{
return right1.Right == right2.Right;
}
/// <summary>
/// Determines whether two access rights are not equal.
/// </summary>
/// <remarks>
/// Determines whether two access rights are not equal.
/// </remarks>
/// <returns><c>true</c> if <paramref name="right1"/> and <paramref name="right2"/> are not equal; otherwise, <c>false</c>.</returns>
/// <param name="right1">The first access right to compare.</param>
/// <param name="right2">The second access right to compare.</param>
public static bool operator != (AccessRight right1, AccessRight right2)
{
return right1.Right != right2.Right;
}
/// <summary>
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="MailKit.AccessRight"/>.
/// </summary>
/// <remarks>
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="MailKit.AccessRight"/>.
/// </remarks>
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="MailKit.AccessRight"/>.</param>
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current <see cref="MailKit.AccessRight"/>;
/// otherwise, <c>false</c>.</returns>
public override bool Equals (object obj)
{
return obj is AccessRight && ((AccessRight) obj).Right == Right;
}
/// <summary>
/// Serves as a hash function for a <see cref="MailKit.AccessRight"/> object.
/// </summary>
/// <remarks>
/// Serves as a hash function for a <see cref="MailKit.AccessRight"/> object.
/// </remarks>
/// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a hash table.</returns>
public override int GetHashCode ()
{
return Right.GetHashCode ();
}
/// <summary>
/// Returns a <see cref="System.String"/> that represents the current <see cref="MailKit.AccessRight"/>.
/// </summary>
/// <remarks>
/// Returns a <see cref="System.String"/> that represents the current <see cref="MailKit.AccessRight"/>.
/// </remarks>
/// <returns>A <see cref="System.String"/> that represents the current <see cref="MailKit.AccessRight"/>.</returns>
public override string ToString ()
{
return Right.ToString ();
}
}
}

View File

@ -1,317 +0,0 @@
//
// AccessRights.cs
//
// Author: Jeffrey Stedfast <jestedfa@microsoft.com>
//
// 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;
using System.Collections;
using System.Collections.Generic;
namespace MailKit {
/// <summary>
/// A set of access rights.
/// </summary>
/// <remarks>
/// The set of access rights for a particular identity.
/// </remarks>
public class AccessRights : ICollection<AccessRight>
{
readonly List<AccessRight> list = new List<AccessRight> ();
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AccessRights"/> class.
/// </summary>
/// <remarks>
/// Creates a new set of access rights.
/// </remarks>
/// <param name="rights">The access rights.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="rights"/> is <c>null</c>.
/// </exception>
public AccessRights (IEnumerable<AccessRight> rights)
{
AddRange (rights);
}
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AccessRights"/> class.
/// </summary>
/// <remarks>
/// Creates a new set of access rights.
/// </remarks>
/// <param name="rights">The access rights.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="rights"/> is <c>null</c>.
/// </exception>
public AccessRights (string rights)
{
AddRange (rights);
}
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AccessRights"/> class.
/// </summary>
/// <remarks>
/// Creates an empty set of access rights.
/// </remarks>
public AccessRights ()
{
}
/// <summary>
/// Get the number of access rights in the collection.
/// </summary>
/// <remarks>
/// Gets the number of access rights in the collection.
/// </remarks>
/// <value>The count.</value>
public int Count {
get { return list.Count; }
}
/// <summary>
/// Get whether or not this set of access rights is read only.
/// </summary>
/// <remarks>
/// Gets whether or not this set of access rights is read only.
/// </remarks>
/// <value><c>true</c> if this collection is read only; otherwise, <c>false</c>.</value>
public bool IsReadOnly {
get { return false; }
}
/// <summary>
/// Add the specified access right.
/// </summary>
/// <remarks>
/// Adds the specified access right if it is not already included.
/// </remarks>
/// <param name="right">The access right.</param>
void ICollection<AccessRight>.Add (AccessRight right)
{
Add (right);
}
/// <summary>
/// Add the specified access right.
/// </summary>
/// <remarks>
/// Adds the specified access right if it is not already included.
/// </remarks>
/// <returns><c>true</c> if the right was added; otherwise, <c>false</c>.</returns>
/// <param name="right">The access right.</param>
public bool Add (AccessRight right)
{
if (list.Contains (right))
return false;
list.Add (right);
return true;
}
/// <summary>
/// Add the specified right.
/// </summary>
/// <remarks>
/// Adds the right specified by the given character.
/// </remarks>
/// <returns><c>true</c> if the right was added; otherwise, <c>false</c>.</returns>
/// <param name="right">The right.</param>
public bool Add (char right)
{
return Add (new AccessRight (right));
}
/// <summary>
/// Add the rights specified by the characters in the given string.
/// </summary>
/// <remarks>
/// Adds the rights specified by the characters in the given string.
/// </remarks>
/// <param name="rights">The rights.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="rights"/> is <c>null</c>.
/// </exception>
public void AddRange (string rights)
{
if (rights == null)
throw new ArgumentNullException (nameof (rights));
for (int i = 0; i < rights.Length; i++)
Add (new AccessRight (rights[i]));
}
/// <summary>
/// Add the range of specified rights.
/// </summary>
/// <remarks>
/// Adds the range of specified rights.
/// </remarks>
/// <param name="rights">The rights.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="rights"/> is <c>null</c>.
/// </exception>
public void AddRange (IEnumerable<AccessRight> rights)
{
if (rights == null)
throw new ArgumentNullException (nameof (rights));
foreach (var right in rights)
Add (right);
}
/// <summary>
/// Clears the access rights.
/// </summary>
/// <remarks>
/// Removes all of the access rights.
/// </remarks>
public void Clear ()
{
list.Clear ();
}
/// <summary>
/// Checks if the set of access rights contains the specified right.
/// </summary>
/// <remarks>
/// Determines whether or not the set of access rights already contains the specified right
/// </remarks>
/// <returns><value>true</value> if the specified right exists; otherwise <value>false</value>.</returns>
/// <param name="right">The access right.</param>
public bool Contains (AccessRight right)
{
return list.Contains (right);
}
/// <summary>
/// Copies all of the access rights to the specified array.
/// </summary>
/// <remarks>
/// Copies all of the access rights into the array,
/// starting at the specified array index.
/// </remarks>
/// <param name="array">The array.</param>
/// <param name="arrayIndex">The array index.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="array"/> is <c>null</c>.
/// </exception>
/// <exception cref="System.ArgumentOutOfRangeException">
/// <paramref name="arrayIndex"/> is out of range.
/// </exception>
public void CopyTo (AccessRight[] array, int arrayIndex)
{
if (array == null)
throw new ArgumentNullException (nameof (array));
if (arrayIndex < 0 || arrayIndex + Count > array.Length)
throw new ArgumentOutOfRangeException (nameof (arrayIndex));
list.CopyTo (array, arrayIndex);
}
/// <summary>
/// Removes the specified access right.
/// </summary>
/// <remarks>
/// Removes the specified access right.
/// </remarks>
/// <returns><value>true</value> if the access right was removed; otherwise <value>false</value>.</returns>
/// <param name="right">The access right.</param>
public bool Remove (AccessRight right)
{
return list.Remove (right);
}
/// <summary>
/// Get the access right at the specified index.
/// </summary>
/// <remarks>
/// Gets the access right at the specified index.
/// </remarks>
/// <value>The access right at the specified index.</value>
/// <param name="index">The index.</param>
/// <exception cref="System.ArgumentOutOfRangeException">
/// <paramref name="index"/> is out of range.
/// </exception>
public AccessRight this [int index] {
get {
if (index < 0 || index >= list.Count)
throw new ArgumentOutOfRangeException (nameof (index));
return list[index];
}
}
#region IEnumerable implementation
/// <summary>
/// Get the access rights enumerator.
/// </summary>
/// <remarks>
/// Gets the access rights enumerator.
/// </remarks>
/// <returns>The enumerator.</returns>
public IEnumerator<AccessRight> GetEnumerator ()
{
return list.GetEnumerator ();
}
#endregion
#region IEnumerable implementation
/// <summary>
/// Get the access rights enumerator.
/// </summary>
/// <remarks>
/// Gets the access rights enumerator.
/// </remarks>
/// <returns>The enumerator.</returns>
IEnumerator IEnumerable.GetEnumerator ()
{
return list.GetEnumerator ();
}
#endregion
/// <summary>
/// Return a <see cref="System.String"/> that represents the current <see cref="MailKit.AccessRights"/>.
/// </summary>
/// <remarks>
/// Returns a <see cref="System.String"/> that represents the current <see cref="MailKit.AccessRights"/>.
/// </remarks>
/// <returns>A <see cref="System.String"/> that represents the current <see cref="MailKit.AccessRights"/>.</returns>
public override string ToString ()
{
var rights = new char[list.Count];
for (int i = 0; i < list.Count; i++)
rights[i] = list[i].Right;
return new string (rights);
}
}
}

View File

@ -1,69 +0,0 @@
//
// AlertEventArgs.cs
//
// Author: Jeffrey Stedfast <jestedfa@microsoft.com>
//
// 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 {
/// <summary>
/// Alert event arguments.
/// </summary>
/// <remarks>
/// Some <see cref="IMailStore"/> implementations, such as
/// <see cref="MailKit.Net.Imap.ImapClient"/>, will emit Alert
/// events when they receive alert messages from the server.
/// </remarks>
public class AlertEventArgs : EventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AlertEventArgs"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="AlertEventArgs"/>.
/// </remarks>
/// <param name="message">The alert message.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="message"/> is <c>null</c>.
/// </exception>
public AlertEventArgs (string message)
{
if (message == null)
throw new ArgumentNullException (nameof (message));
Message = message;
}
/// <summary>
/// Gets the alert message.
/// </summary>
/// <remarks>
/// The alert message will be the exact message received from the server.
/// </remarks>
/// <value>The alert message.</value>
public string Message {
get; private set;
}
}
}

View File

@ -1,81 +0,0 @@
//
// Annotation.cs
//
// Author: Jeffrey Stedfast <jestedfa@microsoft.com>
//
// 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;
using System.Collections.Generic;
namespace MailKit {
/// <summary>
/// An annotation.
/// </summary>
/// <remarks>
/// <para>An annotation.</para>
/// <para>For more information about annotations, see
/// <a href="https://tools.ietf.org/html/rfc5257">rfc5257</a>.</para>
/// </remarks>
public class Annotation
{
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.Annotation"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="Annotation"/>.
/// </remarks>
/// <param name="entry">The annotation entry.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="entry"/> is <c>null</c>.
/// </exception>
public Annotation (AnnotationEntry entry)
{
if (entry == null)
throw new ArgumentNullException (nameof (entry));
Properties = new Dictionary<AnnotationAttribute, string> ();
Entry = entry;
}
/// <summary>
/// Get the annotation tag.
/// </summary>
/// <remarks>
/// Gets the annotation tag.
/// </remarks>
/// <value>The annotation tag.</value>
public AnnotationEntry Entry {
get; private set;
}
/// <summary>
/// Get the annotation properties.
/// </summary>
/// <remarks>
/// Gets the annotation properties.
/// </remarks>
public Dictionary<AnnotationAttribute, string> Properties {
get; private set;
}
}
}

View File

@ -1,53 +0,0 @@
//
// AnnotationAccess.cs
//
// Author: Jeffrey Stedfast <jestedfa@microsoft.com>
//
// 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.
//
namespace MailKit {
/// <summary>
/// An annotation access level.
/// </summary>
/// <remarks>
/// <para>An annotation access level.</para>
/// <para>For more information about annotations, see
/// <a href="https://tools.ietf.org/html/rfc5257">rfc5257</a>.</para>
/// </remarks>
public enum AnnotationAccess
{
/// <summary>
/// Annotations are not supported.
/// </summary>
None,
/// <summary>
/// Annotations are read-only.
/// </summary>
ReadOnly,
/// <summary>
/// Annotations are read-write.
/// </summary>
ReadWrite
}
}

View File

@ -1,251 +0,0 @@
//
// AnnotationAttribute.cs
//
// Author: Jeffrey Stedfast <jestedfa@microsoft.com>
//
// 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 {
/// <summary>
/// An annotation attribute.
/// </summary>
/// <remarks>
/// <para>An annotation attribute.</para>
/// <para>For more information about annotations, see
/// <a href="https://tools.ietf.org/html/rfc5257">rfc5257</a>.</para>
/// </remarks>
public class AnnotationAttribute : IEquatable<AnnotationAttribute>
{
static readonly char[] Wildcards = { '*', '%' };
/// <summary>
/// The annotation value.
/// </summary>
/// <remarks>
/// Used to get or set both the private and shared values of an annotation.
/// </remarks>
public static readonly AnnotationAttribute Value = new AnnotationAttribute ("value", AnnotationScope.Both);
/// <summary>
/// The shared annotation value.
/// </summary>
/// <remarks>
/// Used to get or set the shared value of an annotation.
/// </remarks>
public static readonly AnnotationAttribute SharedValue = new AnnotationAttribute ("value", AnnotationScope.Shared);
/// <summary>
/// The private annotation value.
/// </summary>
/// <remarks>
/// Used to get or set the private value of an annotation.
/// </remarks>
public static readonly AnnotationAttribute PrivateValue = new AnnotationAttribute ("value", AnnotationScope.Private);
/// <summary>
/// The size of an annotation value.
/// </summary>
/// <remarks>
/// Used to get the size of the both the private and shared annotation values.
/// </remarks>
public static readonly AnnotationAttribute Size = new AnnotationAttribute ("size", AnnotationScope.Both);
/// <summary>
/// The size of a shared annotation value.
/// </summary>
/// <remarks>
/// Used to get the size of a shared annotation value.
/// </remarks>
public static readonly AnnotationAttribute SharedSize = new AnnotationAttribute ("size", AnnotationScope.Shared);
/// <summary>
/// The size of a private annotation value.
/// </summary>
/// <remarks>
/// Used to get the size of a private annotation value.
/// </remarks>
public static readonly AnnotationAttribute PrivateSize = new AnnotationAttribute ("size", AnnotationScope.Private);
AnnotationAttribute (string name, AnnotationScope scope)
{
switch (scope) {
case AnnotationScope.Shared: Specifier = string.Format ("{0}.shared", name); break;
case AnnotationScope.Private: Specifier = string.Format ("{0}.priv", name); break;
default: Specifier = name; break;
}
Scope = scope;
Name = name;
}
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AnnotationAttribute"/> class.
/// </summary>
/// <param name="specifier">The annotation attribute specifier.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="specifier"/> is <c>null</c>.
/// </exception>
/// <exception cref="System.ArgumentException">
/// <paramref name="specifier"/> contains illegal characters.
/// </exception>
public AnnotationAttribute (string specifier)
{
if (specifier == null)
throw new ArgumentNullException (nameof (specifier));
if (specifier.Length == 0)
throw new ArgumentException ("Annotation attribute specifiers cannot be empty.", nameof (specifier));
// TODO: improve validation
if (specifier.IndexOfAny (Wildcards) != -1)
throw new ArgumentException ("Annotation attribute specifiers cannot contain '*' or '%'.", nameof (specifier));
Specifier = specifier;
if (specifier.EndsWith (".shared", StringComparison.Ordinal)) {
Name = specifier.Substring (0, specifier.Length - ".shared".Length);
Scope = AnnotationScope.Shared;
} else if (specifier.EndsWith (".priv", StringComparison.Ordinal)) {
Name = specifier.Substring (0, specifier.Length - ".priv".Length);
Scope = AnnotationScope.Private;
} else {
Scope = AnnotationScope.Both;
Name = specifier;
}
}
/// <summary>
/// Get the name of the annotation attribute.
/// </summary>
/// <remarks>
/// Gets the name of the annotation attribute.
/// </remarks>
public string Name {
get; private set;
}
/// <summary>
/// Get the scope of the annotation attribute.
/// </summary>
/// <remarks>
/// Gets the scope of the annotation attribute.
/// </remarks>
public AnnotationScope Scope {
get; private set;
}
/// <summary>
/// Get the annotation attribute specifier.
/// </summary>
/// <remarks>
/// Gets the annotation attribute specifier.
/// </remarks>
public string Specifier {
get; private set;
}
#region IEquatable implementation
/// <summary>
/// Determines whether the specified <see cref="MailKit.AnnotationAttribute"/> is equal to the current <see cref="MailKit.AnnotationAttribute"/>.
/// </summary>
/// <remarks>
/// Determines whether the specified <see cref="MailKit.AnnotationAttribute"/> is equal to the current <see cref="MailKit.AnnotationAttribute"/>.
/// </remarks>
/// <param name="other">The <see cref="MailKit.AnnotationAttribute"/> to compare with the current <see cref="MailKit.AnnotationAttribute"/>.</param>
/// <returns><c>true</c> if the specified <see cref="MailKit.AnnotationAttribute"/> is equal to the current
/// <see cref="MailKit.AnnotationAttribute"/>; otherwise, <c>false</c>.</returns>
public bool Equals (AnnotationAttribute other)
{
return other?.Specifier == Specifier;
}
#endregion
/// <summary>
/// Determines whether two annotation attributes are equal.
/// </summary>
/// <remarks>
/// Determines whether two annotation attributes are equal.
/// </remarks>
/// <returns><c>true</c> if <paramref name="attr1"/> and <paramref name="attr2"/> are equal; otherwise, <c>false</c>.</returns>
/// <param name="attr1">The first annotation attribute to compare.</param>
/// <param name="attr2">The second annotation attribute to compare.</param>
public static bool operator == (AnnotationAttribute attr1, AnnotationAttribute attr2)
{
return attr1?.Specifier == attr2?.Specifier;
}
/// <summary>
/// Determines whether two annotation attributes are not equal.
/// </summary>
/// <remarks>
/// Determines whether two annotation attributes are not equal.
/// </remarks>
/// <returns><c>true</c> if <paramref name="attr1"/> and <paramref name="attr2"/> are not equal; otherwise, <c>false</c>.</returns>
/// <param name="attr1">The first annotation attribute to compare.</param>
/// <param name="attr2">The second annotation attribute to compare.</param>
public static bool operator != (AnnotationAttribute attr1, AnnotationAttribute attr2)
{
return attr1?.Specifier != attr2?.Specifier;
}
/// <summary>
/// Determine whether the specified <see cref="System.Object"/> is equal to the current <see cref="MailKit.AnnotationAttribute"/>.
/// </summary>
/// <remarks>
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="MailKit.AnnotationAttribute"/>.
/// </remarks>
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="MailKit.AnnotationAttribute"/>.</param>
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
/// <see cref="MailKit.AnnotationAttribute"/>; otherwise, <c>false</c>.</returns>
public override bool Equals (object obj)
{
return obj is AnnotationAttribute && ((AnnotationAttribute) obj).Specifier == Specifier;
}
/// <summary>
/// Serves as a hash function for a <see cref="MailKit.AnnotationAttribute"/> object.
/// </summary>
/// <remarks>
/// Serves as a hash function for a <see cref="MailKit.AnnotationAttribute"/> object.
/// </remarks>
/// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a hash table.</returns>
public override int GetHashCode ()
{
return Specifier.GetHashCode ();
}
/// <summary>
/// Returns a <see cref="System.String"/> that represents the current <see cref="MailKit.AnnotationAttribute"/>.
/// </summary>
/// <remarks>
/// Returns a <see cref="System.String"/> that represents the current <see cref="MailKit.AnnotationAttribute"/>.
/// </remarks>
/// <returns>A <see cref="System.String"/> that represents the current <see cref="MailKit.AnnotationAttribute"/>.</returns>
public override string ToString ()
{
return Specifier;
}
}
}

View File

@ -1,521 +0,0 @@
//
// Annotationentry.cs
//
// Author: Jeffrey Stedfast <jestedfa@microsoft.com>
//
// 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 {
/// <summary>
/// An annotation entry.
/// </summary>
/// <remarks>
/// <para>An annotation entry.</para>
/// <para>For more information about annotations, see
/// <a href="https://tools.ietf.org/html/rfc5257">rfc5257</a>.</para>
/// </remarks>
public class AnnotationEntry : IEquatable<AnnotationEntry>
{
/// <summary>
/// An annotation entry for a comment on a message.
/// </summary>
/// <remarks>
/// Used to get or set a comment on a message.
/// </remarks>
public static readonly AnnotationEntry Comment = new AnnotationEntry ("/comment", AnnotationScope.Both);
/// <summary>
/// An annotation entry for a private comment on a message.
/// </summary>
/// <remarks>
/// Used to get or set a private comment on a message.
/// </remarks>
public static readonly AnnotationEntry PrivateComment = new AnnotationEntry ("/comment", AnnotationScope.Private);
/// <summary>
/// An annotation entry for a shared comment on a message.
/// </summary>
/// <remarks>
/// Used to get or set a shared comment on a message.
/// </remarks>
public static readonly AnnotationEntry SharedComment = new AnnotationEntry ("/comment", AnnotationScope.Shared);
/// <summary>
/// An annotation entry for flags on a message.
/// </summary>
/// <remarks>
/// Used to get or set flags on a message.
/// </remarks>
public static readonly AnnotationEntry Flags = new AnnotationEntry ("/flags", AnnotationScope.Both);
/// <summary>
/// An annotation entry for private flags on a message.
/// </summary>
/// <remarks>
/// Used to get or set private flags on a message.
/// </remarks>
public static readonly AnnotationEntry PrivateFlags = new AnnotationEntry ("/flags", AnnotationScope.Private);
/// <summary>
/// Aa annotation entry for shared flags on a message.
/// </summary>
/// <remarks>
/// Used to get or set shared flags on a message.
/// </remarks>
public static readonly AnnotationEntry SharedFlags = new AnnotationEntry ("/flags", AnnotationScope.Shared);
/// <summary>
/// An annotation entry for an alternate subject on a message.
/// </summary>
/// <remarks>
/// Used to get or set an alternate subject on a message.
/// </remarks>
public static readonly AnnotationEntry AltSubject = new AnnotationEntry ("/altsubject", AnnotationScope.Both);
/// <summary>
/// An annotation entry for a private alternate subject on a message.
/// </summary>
/// <remarks>
/// Used to get or set a private alternate subject on a message.
/// </remarks>
public static readonly AnnotationEntry PrivateAltSubject = new AnnotationEntry ("/altsubject", AnnotationScope.Private);
/// <summary>
/// An annotation entry for a shared alternate subject on a message.
/// </summary>
/// <remarks>
/// Used to get or set a shared alternate subject on a message.
/// </remarks>
public static readonly AnnotationEntry SharedAltSubject = new AnnotationEntry ("/altsubject", AnnotationScope.Shared);
static void ValidatePath (string path)
{
if (path == null)
throw new ArgumentNullException (nameof (path));
if (path.Length == 0)
throw new ArgumentException ("Annotation entry paths cannot be empty.", nameof (path));
if (path[0] != '/' && path[0] != '*' && path[0] != '%')
throw new ArgumentException ("Annotation entry paths must begin with '/'.", nameof (path));
if (path.Length > 1 && path[1] >= '0' && path[1] <= '9')
throw new ArgumentException ("Annotation entry paths must not include a part-specifier.", nameof (path));
if (path == "*" || path == "%")
return;
char pc = path[0];
for (int i = 1; i < path.Length; i++) {
char c = path[i];
if (c > 127)
throw new ArgumentException ($"Invalid character in annotation entry path: '{c}'.", nameof (path));
if (c >= '0' && c <= '9' && pc == '/')
throw new ArgumentException ("Invalid annotation entry path.", nameof (path));
if ((pc == '/' || pc == '.') && (c == '/' || c == '.'))
throw new ArgumentException ("Invalid annotation entry path.", nameof (path));
pc = c;
}
int endIndex = path.Length - 1;
if (path[endIndex] == '/')
throw new ArgumentException ("Annotation entry paths must not end with '/'.", nameof (path));
if (path[endIndex] == '.')
throw new ArgumentException ("Annotation entry paths must not end with '.'.", nameof (path));
}
static void ValidatePartSpecifier (string partSpecifier)
{
if (partSpecifier == null)
throw new ArgumentNullException (nameof (partSpecifier));
char pc = '\0';
for (int i = 0; i < partSpecifier.Length; i++) {
char c = partSpecifier[i];
if (!((c >= '0' && c <= '9') || c == '.') || (c == '.' && (pc == '.' || pc == '\0')))
throw new ArgumentException ("Invalid part-specifier.", nameof (partSpecifier));
pc = c;
}
if (pc == '.')
throw new ArgumentException ("Invalid part-specifier.", nameof (partSpecifier));
}
AnnotationEntry ()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AnnotationEntry"/> struct.
/// </summary>
/// <remarks>
/// Creates a new <see cref="AnnotationEntry"/>.
/// </remarks>
/// <param name="path">The annotation entry path.</param>
/// <param name="scope">The scope of the annotation.</param>
/// <exception cref="System.ArgumentNullException">
/// <paramref name="path"/> is <c>null</c>.
/// </exception>
/// <exception cref="System.ArgumentException">
/// <paramref name="path"/> is invalid.
/// </exception>
public AnnotationEntry (string path, AnnotationScope scope = AnnotationScope.Both)
{
ValidatePath (path);
switch (scope) {
case AnnotationScope.Private: Entry = path + ".priv"; break;
case AnnotationScope.Shared: Entry = path + ".shared"; break;
default: Entry = path; break;
}
PartSpecifier = null;
Path = path;
Scope = scope;
}
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AnnotationEntry"/> struct.
/// </summary>
/// <remarks>
/// Creates a new <see cref="AnnotationEntry"/> for an individual body part of a message.
/// </remarks>
/// <param name="partSpecifier">The part-specifier of the body part of the message.</param>
/// <param name="path">The annotation entry path.</param>
/// <param name="scope">The scope of the annotation.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="partSpecifier"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="path"/> is <c>null</c>.</para>
/// </exception>
/// <exception cref="System.ArgumentException">
/// <para><paramref name="partSpecifier"/> is invalid.</para>
/// <para>-or-</para>
/// <para><paramref name="path"/> is invalid.</para>
/// </exception>
public AnnotationEntry (string partSpecifier, string path, AnnotationScope scope = AnnotationScope.Both)
{
ValidatePartSpecifier (partSpecifier);
ValidatePath (path);
switch (scope) {
case AnnotationScope.Private: Entry = string.Format ("/{0}{1}.priv", partSpecifier, path); break;
case AnnotationScope.Shared: Entry = string.Format ("/{0}{1}.shared", partSpecifier, path); break;
default: Entry = string.Format ("/{0}{1}", partSpecifier, path); break;
}
PartSpecifier = partSpecifier;
Path = path;
Scope = scope;
}
/// <summary>
/// Initializes a new instance of the <see cref="MailKit.AnnotationEntry"/> struct.
/// </summary>
/// <remarks>
/// Creates a new <see cref="AnnotationEntry"/> for an individual body part of a message.
/// </remarks>
/// <param name="part">The body part of the message.</param>
/// <param name="path">The annotation entry path.</param>
/// <param name="scope">The scope of the annotation.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="part"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="path"/> is <c>null</c>.</para>
/// </exception>
/// <exception cref="System.ArgumentException">
/// <paramref name="path"/> is invalid.
/// </exception>
public AnnotationEntry (BodyPart part, string path, AnnotationScope scope = AnnotationScope.Both)
{
if (part == null)
throw new ArgumentNullException (nameof (part));
ValidatePath (path);
switch (scope) {
case AnnotationScope.Private: Entry = string.Format ("/{0}{1}.priv", part.PartSpecifier, path); break;
case AnnotationScope.Shared: Entry = string.Format ("/{0}{1}.shared", part.PartSpecifier, path); break;
default: Entry = string.Format ("/{0}{1}", part.PartSpecifier, path); break;
}
PartSpecifier = part.PartSpecifier;
Path = path;
Scope = scope;
}
/// <summary>
/// Get the annotation entry specifier.
/// </summary>
/// <remarks>
/// Gets the annotation entry specifier.
/// </remarks>
/// <value>The annotation entry specifier.</value>
public string Entry {
get; private set;
}
/// <summary>
/// Get the part-specifier component of the annotation entry.
/// </summary>
/// <remarks>
/// Gets the part-specifier component of the annotation entry.
/// </remarks>
public string PartSpecifier {
get; private set;
}
/// <summary>
/// Get the path component of the annotation entry.
/// </summary>
/// <remarks>
/// Gets the path component of the annotation entry.
/// </remarks>
public string Path {
get; private set;
}
/// <summary>
/// Get the scope of the annotation.
/// </summary>
/// <remarks>
/// Gets the scope of the annotation.
/// </remarks>
public AnnotationScope Scope {
get; private set;
}
#region IEquatable implementation
/// <summary>
/// Determines whether the specified <see cref="MailKit.AnnotationEntry"/> is equal to the current <see cref="MailKit.AnnotationEntry"/>.
/// </summary>
/// <remarks>
/// Determines whether the specified <see cref="MailKit.AnnotationEntry"/> is equal to the current <see cref="MailKit.AnnotationEntry"/>.
/// </remarks>
/// <param name="other">The <see cref="MailKit.AnnotationEntry"/> to compare with the current <see cref="MailKit.AnnotationEntry"/>.</param>
/// <returns><c>true</c> if the specified <see cref="MailKit.AnnotationEntry"/> is equal to the current
/// <see cref="MailKit.AnnotationEntry"/>; otherwise, <c>false</c>.</returns>
public bool Equals (AnnotationEntry other)
{
return other?.Entry == Entry;
}
#endregion
/// <summary>
/// Determines whether two annotation entries are equal.
/// </summary>
/// <remarks>
/// Determines whether two annotation entries are equal.
/// </remarks>
/// <returns><c>true</c> if <paramref name="entry1"/> and <paramref name="entry2"/> are equal; otherwise, <c>false</c>.</returns>
/// <param name="entry1">The first annotation entry to compare.</param>
/// <param name="entry2">The second annotation entry to compare.</param>
public static bool operator == (AnnotationEntry entry1, AnnotationEntry entry2)
{
return entry1?.Entry == entry2?.Entry;
}
/// <summary>
/// Determines whether two annotation entries are not equal.
/// </summary>
/// <remarks>
/// Determines whether two annotation entries are not equal.
/// </remarks>
/// <returns><c>true</c> if <paramref name="entry1"/> and <paramref name="entry2"/> are not equal; otherwise, <c>false</c>.</returns>
/// <param name="entry1">The first annotation entry to compare.</param>
/// <param name="entry2">The second annotation entry to compare.</param>
public static bool operator != (AnnotationEntry entry1, AnnotationEntry entry2)
{
return entry1?.Entry != entry2?.Entry;
}
/// <summary>
/// Determine whether the specified <see cref="System.Object"/> is equal to the current <see cref="MailKit.AnnotationEntry"/>.