private void RunProcessor(API.Request request, Processor processor, string processorName) { API.Response response = null; try { // Threadpooling response = processor.process(request); } catch (Exception e) { Logger.Error("Failed to process message with processor " + processor.GetType() + " : " + e.Message, e); try { Type responseType = Type.GetType("Gwupe.Cloud.Messaging.Response." + processorName + "Rs"); response = (API.Response)responseType.GetConstructor(Type.EmptyTypes).Invoke(new object[] {}); response.error = "UNKNOWN_ERROR"; response.errorMessage = e.Message; } catch (Exception exception) { Logger.Error("Failed to determine return type for " + processorName); response = new ErrorRs { errorMessage = "Failed to determine return type for " + processorName, error = "INTERNAL_SERVER_ERROR" }; } } finally { SendResponse(response, request); } }
public void processRequest(API.Request request) { String resquestType = request.GetType().Name; String processorName = resquestType.Substring(0, resquestType.Length - 2); API.Response response = null; string processorName = "Process" + processorName; if (ProcessHandlers.ContainsKey(processorName)) { System.Delegate myDelegate = ProcessHandlers[processorName]; response = (API.Response)myDelegate.DynamicInvoke(request); } else { logger.Warn("Failed to find a processor for " + processorName); response = new ErrorRs(request.id, "Failed to find a processor for " + processorName); } sendResponse(response, request); }