public IActionResult GetSensors() { var request = new GetSensorsProcessorRequestVersionOne(); var processor = _processorFactory.Create(request); var result = processor.Execute(); return(result); }
public IActionResult GetRelayState([FromQuery] GetRelayStateRequest request) { var processorRequest = new GetRelayStateProcessorRequestVersionOne() { GpioPin = request.GpioPin }; var processor = _processorFactory.Create(processorRequest); var result = processor.Execute(); return(result); }
private static void TestGreaterThan(IProcessorFactory factory, object superImportantReference) { const int FILTER_VALUE = 10; var processor = factory.Create( ProcessorType.GreaterThan, superImportantReference, FILTER_VALUE); if (processor.TryProcess(FILTER_VALUE - 5)) { throw new InvalidOperationException("This should not have been greater than."); } if (!processor.TryProcess(FILTER_VALUE + 5)) { throw new InvalidOperationException("This should have been greater than."); } if (processor.TryProcess("This isn't a number.")) { throw new InvalidOperationException("This should have failed because the input is invalid."); } if (processor.TryProcess(new object())) { throw new InvalidOperationException("This should have failed because the input is invalid."); } }
public IActionResult UpdateHumidifierTask(UpdateHumidifierTaskRequest request) { var processorRequest = new UpdateHumidifierTaskProcessorRequestVersionOne { CheckInterval = request?.CheckInterval, HumiditySensorGpio = request?.HumiditySensorGpio, TargetHumidity = request?.TargetHumidity, RelayGpio = request?.RelayGpio, JobName = request.JobName }; var processor = _processorFactory.Create(processorRequest); var result = processor.Execute(); return(result); }
private static void TestLessThan(IProcessorFactory factory, object superImportantReference) { const int FILTER_VALUE = 10; var processor = factory.Create( ProcessorType.LessThan, superImportantReference, FILTER_VALUE); if (!processor.TryProcess(FILTER_VALUE - 5)) { throw new InvalidOperationException("This should have been less than."); } if (processor.TryProcess(FILTER_VALUE + 5)) { throw new InvalidOperationException("This should not have been less than."); } if (processor.TryProcess("This isn't a number.")) { throw new InvalidOperationException("This should have failed because the input is invalid."); } if (processor.TryProcess(new object())) { throw new InvalidOperationException("This should have failed because the input is invalid."); } }
private static void TestStringEqual(IProcessorFactory factory, object superImportantReference) { const string FILTER_VALUE = "Hello, World!"; var processor = factory.Create( ProcessorType.StringEqual, superImportantReference, FILTER_VALUE); if (!processor.TryProcess(FILTER_VALUE)) { throw new InvalidOperationException("This should have matched."); } if (processor.TryProcess("Goodbye, Cruel World!")) { throw new InvalidOperationException("This should not have matched."); } if (processor.TryProcess(10)) { throw new InvalidOperationException("This should not have matched."); } if (processor.TryProcess(new object())) { throw new InvalidOperationException("This should not have matched."); } }
public MessageDispatcher(int numberOfProcessors, IProcessorFactory processorFactory) { _processors = Enumerable .Range(0, numberOfProcessors) .Select(i => processorFactory.Create(i.ToString(), this)) .ToList(); foreach (var processor in _processors) { processor.OnDone += Done; } }
private void StartThreads() { var i = 0; while (i++ < _threadCount) { var thread = new ProcessorThread($"{_name} / {i}", _processorFactory.Create()); _threads.Add(thread); thread.Start(); } }
private void StartThreads() { var i = 0; while (i++ < threadCount) { var thread = new ProcessorThread(processorFactory.Create()); threads.Add(thread); thread.Start(); } }
private static void RunRequest(RequestType requestType) { IProcessor internalProcessor = _processorFactory.Create(requestType); Console.WriteLine(internalProcessor.GetResponse()); }
private void StartThreads() { var i = 0; while (i++ < _threadCount) { var thread = new ProcessorThread(string.Format("{0} / {1}", _name, i), _processorFactory.Create()); _threads.Add(thread); thread.Start(); } }
private static void TestStringEqual(IProcessorFactory factory, object superImportantReference) { const string FILTER_VALUE = "Hello, World!"; var processor = factory.Create( ProcessorType.StringEqual, superImportantReference, FILTER_VALUE); if (!processor.TryProcess(FILTER_VALUE)) { throw new InvalidOperationException("This should have matched."); } if (processor.TryProcess("Goodbye, Cruel World!")) { throw new InvalidOperationException("This should not have matched."); } if (processor.TryProcess(10)) { throw new InvalidOperationException("This should not have matched."); } if (processor.TryProcess(new object())) { throw new InvalidOperationException("This should not have matched."); } }