示例#1
0
		public ImapReplayCommand (string command, ImapReplayCommandResponse response)
		{
			var tokens = command.Split (' ');
			var cmd = (tokens[1] == "UID" ? tokens[2] : tokens[1]).TrimEnd ();
			var tag = tokens[0];

			var text = string.Format ("{0} {1} {2} completed\r\n", tag, response, cmd);
			Response = Encoding.ASCII.GetBytes (text);
			Command = command;
		}
示例#2
0
        public ImapReplayCommand(string command, ImapReplayCommandResponse response)
        {
            var tokens = command.Split(' ');
            var cmd    = (tokens[1] == "UID" ? tokens[2] : tokens[1]).TrimEnd();
            var tag    = tokens[0];

            var text = string.Format("{0} {1} {2} completed\r\n", tag, response, cmd);

            Response = Encoding.ASCII.GetBytes(text);
            Command  = command;
        }
示例#3
0
        public ImapReplayCommand(Encoding encoding, string command, ImapReplayCommandResponse response, bool compressed = false)
        {
            CommandBuffer = encoding.GetBytes(command);
            Compressed    = compressed;
            Encoding      = encoding;
            Command       = command;

            string text;

            if (response == ImapReplayCommandResponse.Plus)
            {
                text = "+\r\n";
            }
            else
            {
                var tokens = command.Split(' ');
                var cmd    = (tokens [1] == "UID" ? tokens [2] : tokens [1]).TrimEnd();
                var tag    = tokens [0];

                text = string.Format("{0} {1} {2} {3}\r\n", tag, response, cmd, response == ImapReplayCommandResponse.OK ? "completed" : "failed");
            }

            if (compressed)
            {
                using (var memory = new MemoryStream()) {
                    using (var compress = new CompressedStream(memory)) {
                        var buffer = encoding.GetBytes(text);

                        compress.Write(buffer, 0, buffer.Length);
                        compress.Flush();

                        Response = memory.ToArray();
                    }
                }

                using (var memory = new MemoryStream()) {
                    using (var compress = new CompressedStream(memory)) {
                        compress.Write(CommandBuffer, 0, CommandBuffer.Length);
                        compress.Flush();

                        CommandBuffer = memory.ToArray();
                    }
                }
            }
            else
            {
                Response = encoding.GetBytes(text);
            }
        }
示例#4
0
 public ImapReplayCommand(string command, ImapReplayCommandResponse response, bool compressed = false) : this(Latin1, command, response, compressed)
 {
 }