private ImapCommandResult GetMetadataInternal(string mailboxName, bool checkName, string[] entrySpecifiers, ImapGetMetadataOptions options, out ImapMetadata[] metadata)
        {
            if (entrySpecifiers == null)
            throw new ArgumentNullException("entrySpecifiers");
              else if (entrySpecifiers.Length == 0)
            throw new ArgumentException("must be non-empty array", "entrySpecifiers");

              if (checkName)
            RejectInvalidMailboxNameArgument(mailboxName);

              if (handlesIncapableAsException)
            CheckServerCapabilityMetadata(mailboxName != null);

              metadata = null;

              using (var t = new GetMetadataTransaction(connection)) {
            // mailbox-name
            t.RequestArguments["mailbox-name"] = (mailboxName == null)
              ? new ImapQuotedString(string.Empty)
              : new ImapMailboxNameString(mailboxName);

            // options
            if (options != null)
              t.RequestArguments["options"] = options;

            // entry-specifier
            if (entrySpecifiers.Length == 1)
              t.RequestArguments["entry-specifier"] = entrySpecifiers[0];
            else
              t.RequestArguments["entry-specifier"] = new ImapParenthesizedString(entrySpecifiers);

            if (ProcessTransaction(t).Succeeded)
              metadata = t.Result.Value;

            return t.Result;
              }
        }
 private ImapCommandResult GetMetadataInternal(string[] entrySpecifiers, ImapGetMetadataOptions options, out ImapMetadata[] metadata)
 {
     return GetMetadataInternal(null, false, entrySpecifiers, options, out metadata);
 }
        /// <summary>sends GETMETADATA command</summary>
        /// <remarks>
        /// valid in authenticated/selected state.
        /// this method will fail if server does not support METADATA extension.
        /// </remarks>
        public ImapCommandResult GetMetadata(ImapMailbox mailbox, string[] entrySpecifiers, ImapGetMetadataOptions options, out ImapMetadata[] metadata)
        {
            if (options == null)
            throw new ArgumentNullException("options");

              ValidateMailboxRelationship(mailbox);

              return GetMetadataInternal(mailbox.Name, false, entrySpecifiers, options, out metadata);
        }
        /// <summary>sends GETMETADATA command</summary>
        /// <remarks>
        /// valid in authenticated/selected state.
        /// this method will fail if server does not support METADATA extension.
        /// </remarks>
        public ImapCommandResult GetMetadata(string mailboxName, string[] entrySpecifiers, ImapGetMetadataOptions options, out ImapMetadata[] metadata)
        {
            if (options == null)
            throw new ArgumentNullException("options");

              return GetMetadataInternal(mailboxName, true, entrySpecifiers, options, out metadata);
        }
        /// <summary>sends GETMETADATA command</summary>
        /// <remarks>
        /// valid in authenticated/selected state.
        /// this method will fail if server does not support METADATA or METADATA-SERVER extension.
        /// </remarks>
        public ImapCommandResult GetMetadata(string entrySpecifier, ImapGetMetadataOptions options, out ImapMetadata[] metadata)
        {
            if (options == null)
            throw new ArgumentNullException("options");

              return GetMetadataInternal(new[] {entrySpecifier}, options, out metadata);
        }