public ChromelyRequest(string id, RoutePath routePath, IDictionary <string, string> parameters, object postData, string rawJson) { Id = id; RoutePath = routePath; Parameters = parameters; PostData = postData; RawJson = rawJson; }
public IDictionary <string, ActionRoute> GetHttpAttributeRoutes(ChromelyController controller) { if (controller == null) { return(null); } var result = new Dictionary <string, ActionRoute>(); var methodInfos = controller.GetType().GetMethods() .Where(m => m.GetCustomAttributes(typeof(HttpAttribute), false).Length > 0) .ToArray(); foreach (var item in methodInfos) { var httpAttributeDelegate = CreateDelegate(controller, item) as Func <ChromelyRequest, ChromelyResponse>; var asyncHttpAttributeDelegate = CreateDelegate(controller, item) as Func <ChromelyRequest, Task <ChromelyResponse> >; var attribute = item.GetCustomAttribute <HttpAttribute>(); // Sync if (httpAttributeDelegate != null && attribute != null) { var routhPath = new RoutePath(attribute.Method, attribute.Route); result[routhPath.Key] = new ActionRoute(attribute.Method, attribute.Route, httpAttributeDelegate); } // Async if (asyncHttpAttributeDelegate != null && attribute != null) { var routhPath = new RoutePath(attribute.Method, attribute.Route); result[routhPath.Key] = new ActionRoute(attribute.Method, attribute.Route, asyncHttpAttributeDelegate); } } return(result); }
protected void AddRoute(string method, string path, ActionRoute route) { var routhPath = new RoutePath(method, path); ActionRouteDictionary[routhPath.Key] = route; }
public Task <ChromelyResponse> InvokeAsync(string requestId, RoutePath routePath, IDictionary <string, string> parameters, object postData, string rawJson = null) { ChromelyRequest request = new ChromelyRequest(requestId, routePath, parameters, postData, rawJson); return(ActionAsync.Invoke(request)); }
public ChromelyRequest(RoutePath routePath, IDictionary <string, string> parameters, object postData) { RoutePath = routePath; Parameters = parameters; PostData = postData; }