public ControllerAction(WebAPIAttribute webAPI) { Controller = webAPI.BindMethodInfo.DeclaringType.Name; Controller = Controller.Substring(0, Controller.IndexOf("Controller")); Action = webAPI.BindMethodInfo.Name; DebugOnly = webAPI.DebugOnly; if (webAPI.BindMethodInfo.GetCustomAttribute <HttpGetAttribute>() != null) { Type = "HttpGet"; } else if (webAPI.BindMethodInfo.GetCustomAttribute <HttpPostAttribute>() != null) { Type = "HttpPost"; } else { Type = "Error"; } }
private ServerRouteConfig GetNewServerRouteConfig() { List <WebAPIAttribute> WebAPIList = new List <WebAPIAttribute>(); foreach (Type type in Assembly.GetExecutingAssembly().GetTypes()) { WebAPIList.AddRange(WebAPIAttribute.GetWebAPI(type)); } List <ControllerAction> newWebAPIList = new List <ControllerAction>(); foreach (WebAPIAttribute webAPI in WebAPIList) { newWebAPIList.Add(new ControllerAction(webAPI)); } ServerRouteConfig newConfig = new ServerRouteConfig { WebAPI = newWebAPIList.ToArray(), BaseAddress = PortConfig.Value.ServerIPAddressV4, }; return(newConfig); }