从具有强类型的特定控制器获取特定操作的路由列表

时间:2019-02-12 13:30:37

标签: c# .net asp.net-core lambda .net-core

我希望能够获取控制器特定操作的路由。

这是签名。

string extractRoute<T>(Action<T> action)
{
     doing something 

     return string.Empty;
 }

我想这样使用它:

string route1 = extractRoute<SomeController>(x => x.GetAll);
string route2 = extractRoute<SomeController>(x => x.Delete);

结果将存储在集合中

遇到此编译错误

  

仅分配,调用,递增,递减,等待和新对象   表达式可以用作语句

SomeController是一个API控制器

GetAll是该控制器上的一个动作。

Task<ActionResult<SomeResult>> GetAll(Request requesT) 
{
      throw new System.NotImplemented(); 
}

删除是该控制器上的一个动作。

Task<ActionResult<bool>> Delete (int id) 
{
      throw new System.NotImplemented(); 
}

0 个答案:

没有答案