Compare commits
No commits in common. "caac6c0d39c925b0380a1e17260f72e0ea04fc09" and "72dbbde075b8092dd725f18b8a6c70f1a4f366a3" have entirely different histories.
caac6c0d39
...
72dbbde075
@ -45,34 +45,6 @@ namespace PSTW_CentralSystem.Controllers.API
|
|||||||
// Return the list as JSON
|
// Return the list as JSON
|
||||||
return Json(controllerAndMethodList);
|
return Json(controllerAndMethodList);
|
||||||
}
|
}
|
||||||
[HttpPost("GetListClassAndMethodInformation")]
|
|
||||||
public async Task<IActionResult> GetListClassAndMethodInformation()
|
|
||||||
{
|
|
||||||
var controllerAndMethodList = new List<object>();
|
|
||||||
|
|
||||||
// Get the assembly containing the controllers
|
|
||||||
var assembly = Assembly.GetExecutingAssembly();
|
|
||||||
|
|
||||||
// Get all types in the assembly (controllers will typically be in the "Controllers" namespace)
|
|
||||||
//var controllerTypes = await Task.Run(() => assembly.GetTypes().Where(type => typeof(ControllerBase).IsAssignableFrom(type) && type.IsClass && type.Name.Contains("Controller") && type.Name != "AdminController") .ToList());
|
|
||||||
var controllerTypes = await Task.Run(() => assembly.GetTypes().Where(type => typeof(ControllerBase).IsAssignableFrom(type) && type.IsClass && !type.Name.Contains("API") && !type.Name.Contains("Admin")).ToList());
|
|
||||||
|
|
||||||
// Iterate over the controller types and get their methods
|
|
||||||
foreach (var controllerType in controllerTypes) {
|
|
||||||
var methods = controllerType?.GetMethods(BindingFlags.Public | BindingFlags.Instance)
|
|
||||||
.Where(m => m.DeclaringType == controllerType) // Filter methods declared directly in the controller (ignoring inherited ones)
|
|
||||||
.Select(m => m.Name) // Get the method names
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
controllerAndMethodList.Add(new
|
|
||||||
{
|
|
||||||
Controller = controllerType?.Name,
|
|
||||||
Methods = methods
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// Return the list as JSON
|
|
||||||
return Json(controllerAndMethodList);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user