Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 获取对指定方法加上它的所有调用';与Roslyn的参数列表_C#_Lambda_Delegates_Roslyn - Fatal编程技术网

C# 获取对指定方法加上它的所有调用';与Roslyn的参数列表

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以及使

如何根据下面的一些示例代码从Roslyn提取对CallApiAsync的所有调用。例如,在下面的代码中,我希望提取以下调用

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{}