public ICommand Build(string command) { string[] commandSplit = command?.Split(' '); ICommand createdCommand; switch (commandSplit[0]) { case "/help": case "/h": createdCommand = new HelpCommand(); break; case "/version": case "/v": createdCommand = new VersionCommand(); break; case "/clear": createdCommand = new ClearCommand(); break; case "/quit": case "/q": createdCommand = new QuitCommand(); break; case "/post": case "/p": createdCommand = new PostCommand(commandSplit); break; case "/retrieve": case "/r": createdCommand = new RetrieveCommand(commandSplit); break; case "/settings": createdCommand = new SettingsCommand(commandSplit); break; default: createdCommand = new DefaultCommand(); break; } return(createdCommand); }
protected void EnqueueCommand(RetrieveCommand command) { if (!_startCalled) { _uiThreadSynchronizationContext = SynchronizationContext.Current; } OnResultAdded(command.Result); Interlocked.Increment(ref _totalCommandsToExecute); _threadPool.Enqueue(command.Execute); lock (_syncLock) { _threadPool.Start(); _startCalled = true; } }
/// <summary> /// Retrieves the specified message. /// </summary> /// <param name="item">The item.</param> /// <returns>A MimeEntity for the requested Pop3 Mail Item.</returns> public byte[] Retrieve(Pop3ListItemResult item) { if (item == null) { throw new ArgumentNullException("item"); } if (item.MessageId < 1) { throw new ArgumentOutOfRangeException(string.Format("{0}", item.MessageId)); } RetrieveResponse response; using (RetrieveCommand command = new RetrieveCommand(_clientStream, item.MessageId)) { response = ExecuteCommand <RetrieveResponse, RetrieveCommand>(command); } return(response.RawBytes); }
private static byte[] MakeRetriveDataFrame(byte address, RetrieveCommand command) { var dataFrame = new List <byte>(); dataFrame.Add(address); var commandCodes = BitConverter.GetBytes((int)command); dataFrame.Add(commandCodes[2]); // Function Code dataFrame.Add(commandCodes[1]); // Register Address (High) dataFrame.Add(commandCodes[0]); // Register Address (Low) dataFrame.Add(0x00); // Register Count (High) dataFrame.Add(0x01); // Register Count (Low) var crc = CRC16.CalculateCRC(dataFrame.ToArray()); dataFrame.AddRange(crc); return(dataFrame.ToArray()); }
protected void EnqueueCommand(RetrieveCommand command) { if (!_startCalled) _uiThreadSynchronizationContext = SynchronizationContext.Current; OnResultAdded(command.Result); Interlocked.Increment(ref _totalCommandsToExecute); _threadPool.Enqueue(command.Execute); lock (_syncLock) { _threadPool.Start(); _startCalled = true; } }