SearchResponse ISearchService.Search(SearchRequest searchRequest)
 {
     if (searchRequest.CriteriaCount == 0)
     {
         throw new ArgumentException("No criteria specified.", new InvalidOperationException());
     }
     SearchResponse.Builder resp = SearchResponse.CreateBuilder();
     foreach (string criteria in searchRequest.CriteriaList)
     {
         resp.AddResults(
             SearchResponse.Types.ResultItem.CreateBuilder().SetName(criteria).SetUrl("http://search.com").
             Build());
     }
     return(resp.Build());
 }
Example #2
0
    public override void Search(
        Google.ProtocolBuffers.IRpcController controller,
        SearchRequest request,
        System.Action <SearchResponse> done)
    {
        PrintRequest(controller, request);

        // Build the response.
        SearchResponse.Types.Result result = SearchResponse.Types.Result.CreateBuilder()
                                             .SetUrl("http://someurl.com")
                                             .Build();

        SearchResponse response = SearchResponse.CreateBuilder()
                                  .AddResult(result)
                                  .Build();

        PrintResponse(response);

        // Send the response.
        done(response);
    }