Example #1
0
 private static void AddSingularFeature <T>(
     AnnotateImageRequest request,
     AnnotateImageResponse fullResponse,
     AnnotateImageResponse actualResponse,
     FeatureType featureType,
     Func <AnnotateImageResponse, T> extractor,
     Action <AnnotateImageResponse, T> assigner)
 {
     if (request.Features.Any(f => f.Type == featureType))
     {
         assigner(actualResponse, extractor(fullResponse));
     }
 }
        private static void AddRepeatedFeatures <T>(
            AnnotateImageRequest request,
            AnnotateImageResponse fullResponse,
            AnnotateImageResponse actualResponse,
            FeatureType featureType,
            Func <AnnotateImageResponse, RepeatedField <T> > extractor)
        {
            var featureRequest = request.Features.Where(f => f.Type == featureType).FirstOrDefault();

            if (featureRequest == null)
            {
                return;
            }
            var maxEntries = featureRequest.MaxResults == 0 ? int.MaxValue : featureRequest.MaxResults;

            extractor(actualResponse).AddRange(extractor(fullResponse).Take(maxEntries));
        }