private void RegisterMethods(string processingGroup, HttpController httpController) { Type type = httpController.GetType(); //check all methods of the HttpController class foreach (MethodInfo methodInfo in type.GetMethods()) { string path; //load all attributes System.Attribute[] attr = System.Attribute.GetCustomAttributes(methodInfo); foreach (Attribute a in attr) { if (a is Path) { Path pathAttribute = (Path)a; path = pathAttribute.Method.ToString() + pathAttribute.Url; if (!pathAttribute.Url.StartsWith("/")) { throw new Exception("Cannot include method since first parameter does not match target type. Make sure that the first parameter is type of HttpContext."); } if (methodInfo.GetParameters()[0].ParameterType.Name.CompareTo("HttpContext") != 0) { throw new Exception("Cannot include method since first parameter does not match target type. Make sure that the first parameter is type of HttpContext."); } _routingEngine.AddEntry(pathAttribute.Method.ToString() + pathAttribute.Url, processingGroup, httpController, methodInfo); } } } }
public override void AddController(HttpController httpController, string processingGroup, bool multiprocessing) { if (!_httpProcessors.ContainsKey(processingGroup)) { AddProcessor(processingGroup, multiprocessing); } else { //if the existing processing group has not the preferred type if (_httpProcessors[processingGroup].IsMultiProcessor != multiprocessing) { throw new Exception("Cannot add controller since preferred processing group is multiprocessing=" + !multiprocessing); } } //set service reference httpController.Service = this; //set provisional UUID if not set if (httpController.Uuid == null) { httpController.Uuid = httpController.GetType().GUID.ToString() + "_AUTO"; } RegisterMethods(processingGroup, httpController); }