public void Initialize(IEnqueueCommand <WorkshopCommand> workshopCommands) { _addButton.onClick .AsObservable() .Select(_ => CreateAddWorkerCommand()) .Subscribe(workshopCommands.Enqueue); }
public InitializeRouterArrowsWhenLinkAddedAsSource(NodeIdentifier nodeId, IObservable <NetworkEvent> networkEvents, IEnqueueCommand <NetworkCommand> commandQueue) { this.commandQueue = commandQueue; networkEvents .OfType <NetworkEvent, NetworkEvent.LinkAdded>() .Where(linkAdded => linkAdded.Link.Source == nodeId) .Subscribe(linkAdded => Initialize(nodeId, linkAdded.Link.Id)); }
public WorkOnAssignedJobWhenWorkButtonClicked(AssignedJobReadModel assignedJobModel, IWorkButtonClickedObservable workButtonClicked, IEnqueueCommand <WorkshopCommand> workshopCommands, IDisplayProgress displayProgress) { _workshopCommands = workshopCommands; _displayProgress = displayProgress; workButtonClicked .Select(_ => assignedJobModel.AssignedJob) .Subscribe(MaybeWorkOnJob); }
public OnStartTransmission(LinkIdentifier linkId, IObservable <NetworkEvent> networkEvents, IDisplayPacketTransmission displayTransmission, LinkLatencyReadModel linkLatency, IEnqueueCommand <NetworkCommand> commandQueue) { this.displayTransmission = displayTransmission; this.linkLatency = linkLatency; this.commandQueue = commandQueue; networkEvents .OfType <NetworkEvent, NetworkEvent.PacketTransmissionStarted>() .Where(transmissionStarted => transmissionStarted.LinkId == linkId) .Subscribe(transmissionStarted => TransmitPacket(transmissionStarted.PacketId, transmissionStarted.LinkId)); }
private void BuildNetwork(IEnqueueCommand <NetworkCommand> commandQueue) { var node1 = new NodeIdentifier(); var node2 = new NodeIdentifier(); var node3 = new NodeIdentifier(); var linkAttributes = new LinkAttributes(2, 2f); commandQueue.Enqueue(BuildAddNodeCommand(node1, 0, 0)); commandQueue.Enqueue(BuildAddNodeCommand(node2, 4, 4)); commandQueue.Enqueue(BuildAddNodeCommand(node3, -4, -4)); commandQueue.Enqueue(new NetworkCommand.LinkNodes(node1, PortDirection.Right, node2, PortDirection.Bottom, linkAttributes)); commandQueue.Enqueue(new NetworkCommand.LinkNodes(node1, PortDirection.Bottom, node3, PortDirection.Right, linkAttributes)); }
private void BuildNetwork(IEnqueueCommand <NetworkCommand> commandQueue) { var gateway = new NodeIdentifier(); var router = new NodeIdentifier(); var consumer1 = new NodeIdentifier(); var consumer2 = new NodeIdentifier(); var consumer3 = new NodeIdentifier(); var linkAttributes = new LinkAttributes(2, 2f); commandQueue.Enqueue(new NetworkCommand.AddGatewayNode(gateway, new NodePosition(0, 4), 50)); commandQueue.Enqueue(new NetworkCommand.AddRouterNode(router, new NodePosition(0, 0), 5)); commandQueue.Enqueue(new NetworkCommand.AddConsumerNode(consumer1, new NodePosition(4, -4), 5)); commandQueue.Enqueue(new NetworkCommand.AddConsumerNode(consumer2, new NodePosition(-4, -4), 5)); commandQueue.Enqueue(new NetworkCommand.AddConsumerNode(consumer3, new NodePosition(0, -4), 5)); commandQueue.Enqueue(new NetworkCommand.LinkNodes(gateway, PortDirection.Bottom, router, PortDirection.Top, new LinkAttributes(50, .5f))); commandQueue.Enqueue(new NetworkCommand.LinkNodes(router, PortDirection.Right, consumer1, PortDirection.Left, linkAttributes)); commandQueue.Enqueue(new NetworkCommand.LinkNodes(router, PortDirection.Left, consumer2, PortDirection.Right, linkAttributes)); commandQueue.Enqueue(new NetworkCommand.LinkNodes(router, PortDirection.Bottom, consumer3, PortDirection.Top, linkAttributes)); }
public ProcessNodeQueuePeriodically(NodeIdentifier nodeId, IEnqueueCommand <NetworkCommand> commandQueue, TimeSpan period) { Observable.Interval(period) .Subscribe(_ => commandQueue.Enqueue(new NetworkCommand.ProcessNodeQueue(nodeId))); }
private void AddPacket(NodeIdentifier nodeId, IEnqueueCommand <NetworkCommand> commandQueue) { commandQueue.Enqueue(new NetworkCommand.AddPacket(new PacketIdentifier(), RandomPacketType, nodeId)); }
public AddPacketsPeriodically(NodeIdentifier nodeId, IEnqueueCommand <NetworkCommand> commandQueue) { Observable.Interval(TimeSpan.FromSeconds(.1f)) //Observable.Timer(TimeSpan.FromSeconds(1)) .Subscribe(_ => AddPacket(nodeId, commandQueue)); }
public BuildLevel(IEnqueueCommand <NetworkCommand> commandQueue) { Observable.Timer(TimeSpan.FromSeconds(1)) .Subscribe(_ => BuildNetwork(commandQueue)); }
public IncrementPacketTypeDirectionWhenArrowClicked(IArrowClickedObservable arrowClicks, NodeIdentifier nodeId, IEnqueueCommand <NetworkCommand> enqueueCommand) { arrowClicks .Select(packetType => BuildCommand(packetType, nodeId)) .Subscribe(enqueueCommand.Enqueue); }
public CreateNodeAfterDelay(IEnqueueCommand <NetworkCommand> commandQueue) { Observable.Timer(TimeSpan.FromSeconds(1)) .Subscribe(_ => BuildNetwork(commandQueue)); }