MailKit.Net.Imap.ImapCommand.RegisterUntaggedHandler C# (CSharp) Method

RegisterUntaggedHandler() public method

Registers the untagged handler for the specified atom token.
/// is null. /// -or- /// is null. /// /// Untagged handlers must be registered before the command has been queued. ///
public RegisterUntaggedHandler ( string atom, ImapUntaggedHandler handler ) : void
atom string The atom token.
handler ImapUntaggedHandler The handler.
return void
		public void RegisterUntaggedHandler (string atom, ImapUntaggedHandler handler)
		{
			if (atom == null)
				throw new ArgumentNullException (nameof (atom));

			if (handler == null)
				throw new ArgumentNullException (nameof (handler));

			if (Status != ImapCommandStatus.Created)
				throw new InvalidOperationException ("Untagged handlers must be registered before the command has been queued.");

			UntaggedHandlers.Add (atom, handler);
		}

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Queries the namespaces.
        /// </summary>
        /// <returns>The command result.</returns>
        /// <param name="cancellationToken">The cancellation token.</param>
        public ImapCommandResult QueryNamespaces(CancellationToken cancellationToken)
        {
            if (stream == null)
                throw new InvalidOperationException ();

            ImapCommand ic;

            if ((Capabilities & ImapCapabilities.Namespace) != 0) {
                ic = QueueCommand (cancellationToken, null, "NAMESPACE\r\n");
                Wait (ic);
            } else {
                var list = new List<ImapFolder> ();

                ic = new ImapCommand (this, cancellationToken, null, "LIST \"\" \"\"\r\n");
                ic.RegisterUntaggedHandler ("LIST", ImapUtils.ParseFolderList);
                ic.UserData = list;

                QueueCommand (ic);
                Wait (ic);

                PersonalNamespaces.Clear ();
                SharedNamespaces.Clear ();
                OtherNamespaces.Clear ();

                if (list.Count > 0) {
                    PersonalNamespaces.Add (new FolderNamespace (list[0].DirectorySeparator, ""));
                    list[0].IsNamespace = true;
                }

                LookupParentFolders (list, cancellationToken);
            }

            return ic.Result;
        }
All Usage Examples Of MailKit.Net.Imap.ImapCommand::RegisterUntaggedHandler