コード例 #1
0
ファイル: StoreCommand.cs プロジェクト: garath/mail-server
        protected override bool TryParseArguments(ImmutableList <IMessageData> arguments)
        {
            if (arguments.Count != 3)
            {
                return(false);
            }

            string storeType = MessageData.GetString(arguments[0], Encoding.ASCII);

            _messageRange = arguments[1] as NumberRangeMessageData;
            _valueList    = arguments[2] as ListMessageData;

            if (string.IsNullOrEmpty(storeType) ||
                _messageRange == null ||
                _valueList == null)
            {
                return(false);
            }

            Match argumentMatch = ArgumentPattern.Match(storeType);

            if (!argumentMatch.Success)
            {
                return(false);
            }

            switch (argumentMatch.Groups[1].Value)
            {
            case "":
                _operation = StoreOperation.Set;
                break;

            case "+":
                _operation = StoreOperation.Add;
                break;

            case "-":
                _operation = StoreOperation.Remove;
                break;

            default:
                return(false);
            }

            _command = argumentMatch.Groups[2].Value;

            if (!KnownCommands.Contains(_command, StringComparer.OrdinalIgnoreCase))
            {
                return(false);
            }

            _silent = string.Equals(argumentMatch.Groups[3].Value, ".SILENT", StringComparison.OrdinalIgnoreCase);

            return(true);
        }
コード例 #2
0
ファイル: FetchCommand.cs プロジェクト: garath/mail-server
        protected override bool TryParseArguments(ImmutableList <IMessageData> arguments)
        {
            if (arguments.Count != 2)
            {
                return(false);
            }

            _messageSet = arguments[0] as NumberRangeMessageData;
            if (_messageSet == null)
            {
                return(false);
            }

            var list = arguments[1] as ListMessageData;

            if (list == null || list.Items.Count == 0)
            {
                return(false);
            }

            _fetchItems = ResolveAliases(list.Items.Select(i => MessageData.GetString(i, Encoding.UTF8)));
            return(true);
        }