1

내가 BatchRequestsGoogle 디렉토리의 API - 한 BatchRequest

와 .NET 클라이언트 라이브러리의 일부 구글 디렉토리 API 호출 속도를 높이기 위해 노력하고의 결과로 직렬화 객체를 얻기 위해 어떻게 구성되어있는 (내가 다음 batchRequest이 있다고 할 수 있습니다 단 단순 하나 개 요청)의 :

static async Task BatchRequesting() 
    { 
     var batchReq = new BatchRequest(_dirservices[0]); 

     var r = _dirservices[0].Users.Get("[email protected]"); 
     batchReq.Queue<UsersResource.GetRequest>(r, 
      (contentReq, error, j, message) => 
     { 
       ... what to do here? 
     }); 

     await batchReq.ExecuteAsync(); 
    } 

난 내 경우에 사용자 객체가 될 것 콜백의 결과 직렬화 된 응답 객체() 내가 message.Content 개체를 처리해야 하는가를 얻는 방법 (HttpContent) 모든 json deserializing 함께 자신?

답변

1

해결책을 찾았습니다. 잘못된 일반 매개 변수를 사용했습니다. 내 코드 예제는 다음과 같아야합니다.

static async Task BatchRequesting() 
{ 
    var batchReq = new BatchRequest(_directoryService); 

    var request = _directoryService.Users.Get("[email protected]"); 
    batchReq.Queue<User>(request, 
     (returnedUser, error, j, message) => 
    { 
      if (error != null) 
      { 
       Console.WriteLine(error.Message); 
      } 
      else 
      { 
      ... work with returnedUser 
      } 
    }); 

    await batchReq.ExecuteAsync(); 
}