protected void Publish(string url) { using (var mqClient = _mQServer.CreateMessageQueueClient()) { BusMirror.TryAdd(url, false); mqClient.Publish(new Url { Path = url, }); // Now wait for the response IMessage <UrlResponse> responseMsg = mqClient.Get <UrlResponse>(QueueNames <UrlResponse> .In, TimeSpan.FromSeconds(180)); mqClient.Ack(responseMsg); var response = responseMsg.GetBody(); // Log response _writer.Write(response.Response); // Parse for new links if (!_options.IgnoreLinks) { Add(response.Links); } // Update the BusMirror to reflect processing is complete BusMirror.TryUpdate(url, true, false); if (Progress != null) { Progress(this, new ProgressEventArgs { Count = BusMirror.Count, Remaining = QueueSize }); } } }
public void Draw(IWriterService writerService) { if (_lastRemovedPoint.HasValue) { writerService.SetWritePosition(_lastRemovedPoint.Value.Y, _lastRemovedPoint.Value.X); writerService.WriteLine(" "); } if (_isFirstDraw) { foreach (var p in _activePoints) { writerService.SetWritePosition(p.Y, p.X); writerService.Write("S"); } _isFirstDraw = false; } writerService.SetWritePosition(HeadCoordinates.Y, HeadCoordinates.X); writerService.Write("S"); writerService.SetWritePosition(32, 0); }
public void Draw(IWriterService writerService) { writerService.Clear(); var border = new string('#', BottomRightCoordinates.X - UpperLeftCoordinates.X); writerService.SetWritePosition(UpperLeftCoordinates.Y, UpperLeftCoordinates.X); writerService.WriteLine(border); for (int i = UpperLeftCoordinates.Y + 1; i < BottomRightCoordinates.Y - 1; i++) { writerService.SetWritePosition(i, UpperLeftCoordinates.X); writerService.Write("#"); writerService.SetWritePosition(i, BottomRightCoordinates.X - 1); writerService.WriteLine("#"); } writerService.WriteLine(border); }
private void SpawnNewFood() { var random = new Random(); while (true) { var x = random.Next(_gameArea.UpperLeftCoordinates.X + 1, _gameArea.BottomRightCoordinates.X - 1); var y = random.Next(_gameArea.UpperLeftCoordinates.Y + 1, _gameArea.BottomRightCoordinates.Y - 1); var foodPoint = new Point(x, y); if (_snake.ActivePoints.Any(p => p == foodPoint) || _snake.HeadCoordinates == foodPoint) { continue; } _foodPosition = foodPoint; _writerService.SetWritePosition(foodPoint.Y, foodPoint.X); _writerService.Write("*"); break; } }
/// <summary> /// <para>Write using the default encoding <see cref="Encoding.Default"/></para> /// <para>This extension will be available to all implementers of <see cref="IWriterService"/></para> /// </summary> public static void Write(this IWriterService writer, string content) { writer.Write(content, Encoding.Default); }
public void SaveToFile(IWriterService writerService) { writerService.Write(_animals); }