public static StoreArgs ParseStoreArgs(string args) { string[] parts = args.Split(new char[] { ' ' }, 3); if (parts.Length != 3) { throw new Exception("Error in arguments."); } var result = new StoreArgs { Ranges = ImapHelper.GetSequenceRange(parts[0]) }; switch (parts[1].ToUpperInvariant()) { case "FLAGS": result.DataItem = "FLAGS"; result.Silent = false; break; case "FLAGS.SILENT": result.DataItem = "FLAGS"; result.Silent = true; break; case "+FLAGS": result.DataItem = "+FLAGS"; result.Silent = false; break; case "+FLAGS.SILENT": result.DataItem = "+FLAGS"; result.Silent = true; break; case "-FLAGS": result.DataItem = "-FLAGS"; result.Silent = false; break; case "-FLAGS.SILENT": result.DataItem = "-FLAGS"; result.Silent = false; break; default: throw new Exception("Error in arguments."); } if (!(parts[2].StartsWith("(") && parts[2].EndsWith(")"))) { throw new Exception("Error in arguments."); } var spl = parts[2].Substring(1, parts[2].Length - 2).Split(' '); result.Flags = new HashSet <string>(spl.Select(o => o.TrimStart('\\'))).ToArray(); return(result); }
public static CopyArgs ParseArgs(string args) { var parts = args.Split(new char[] { ' ' }, 2); if (parts.Length != 2) { throw new Exception("Error in arguments."); } return(new CopyArgs { Ranges = ImapHelper.GetSequenceRange(parts[0]), FolderName = IMAP_Utils.DecodeMailbox(TextUtils.UnQuoteString(parts[1])) }); }