C# 获取对指定方法加上它的所有调用';与Roslyn的参数列表
如何根据下面的一些示例代码从Roslyn提取对CallApiAsync的所有调用。例如,在下面的代码中,我希望提取以下调用C# 获取对指定方法加上它的所有调用';与Roslyn的参数列表,c#,lambda,delegates,roslyn,C#,Lambda,Delegates,Roslyn,如何根据下面的一些示例代码从Roslyn提取对CallApiAsync的所有调用。例如,在下面的代码中,我希望提取以下调用 CallApiAsync<ISomeApi, SomeResponseType>(x => x.GetResponse(new SomeRequestType())); callapisync(x=>x.GetResponse(newsomerequesttype()); 并且能够提取通用argsISomeApi、SomeResponseType以及使
CallApiAsync<ISomeApi, SomeResponseType>(x => x.GetResponse(new SomeRequestType()));
callapisync(x=>x.GetResponse(newsomerequesttype());
并且能够提取通用argsISomeApi、SomeResponseType以及使用参数SomeRequestType调用的lambda表达式方法
public class ApiWrapper
{
public delegate TResult ApiMethodAsync<T, TResult>(T api);
public virtual SomeResponseType MakeSomeRequestToApi()
{
return CallApiAsync<ISomeApi, SomeResponseType>(x => x.GetResponse(new SomeRequestType()));
}
public virtual TResult CallApiAsync<T, TResult>(ApiMethodAsync<T, TResult> apiMethod) where TResult : new()
{
return new TResult();
}
}
public interface ISomeApi
{
SomeResponseType GetResponse(SomeRequestType request);
}
public class SomeResponseType { }
public class SomeRequestType { }
公共类ApiWrapper
{
公共委托tresultapimethodasync(tapi);
公共虚拟SomeResponseType MakeSomeRequestToApi()
{
返回callapisync(x=>x.GetResponse(newsomeRequestType());
}
公共虚拟TResult callapiaasync(ApiMethodAsync apiMethod),其中TResult:new()
{
返回新的TResult();
}
}
公共接口API
{
SomeResponseType GetResponse(SomeRequestType请求);
}
公共类SomeResponseType{}
公共类SomeRequestType{}