public virtual ImageInsightResponse GetImageInsights(
     string query                     = "",
     int height                       = 0,
     int width                        = 0,
     int count                        = 0,
     int offset                       = 0,
     string languageCode              = "",
     AspectOptions aspect             = AspectOptions.All,
     ColorOptions color               = ColorOptions.All,
     FreshnessOptions freshness       = FreshnessOptions.All,
     ImageContentOptions imageContent = ImageContentOptions.All,
     ImageTypeOptions imageType       = ImageTypeOptions.All,
     LicenseOptions license           = LicenseOptions.All,
     SizeOptions size                 = SizeOptions.All,
     SafeSearchOptions safeSearch     = SafeSearchOptions.Off,
     List <ModulesRequestedOptions> modulesRequested = null,
     float cab            = 0f,
     float cal            = 0f,
     float car            = 0f,
     float cat            = 0f,
     int ct               = 0,
     string cc            = "",
     string id            = "",
     string imgUrl        = "",
     string insightsToken = "")
 {
     return(Task.Run(async() => await GetImageInsightsAsync(query, height, width, count, offset, languageCode, aspect, color, freshness, imageContent, imageType, license, size, safeSearch, modulesRequested, cab, cal, car, cat, ct, cc, id, imgUrl, insightsToken)).Result);
 }
        public static string ConvertToCss(SizeOptions sizeOption)
        {
            string sizeStr = null;

            switch (sizeOption)
            {
            case SizeOptions.Large:
                sizeStr = "lg";
                break;

            case SizeOptions.Small:
                sizeStr = "sm";
                break;

            case SizeOptions.ExtraSmall:
                sizeStr = "xs";
                break;

            default:
                sizeStr = sizeOption.ToString().ToLower();
                break;
            }

            return(ControlTypeAbbr + "-" + sizeStr);
        }
Beispiel #3
0
        public virtual async Task <ImageInsightResponse> GetImageInsightsAsync(
            string query                     = "",
            int height                       = 0,
            int width                        = 0,
            int count                        = 0,
            int offset                       = 0,
            string languageCode              = "",
            AspectOptions aspect             = AspectOptions.All,
            ColorOptions color               = ColorOptions.All,
            FreshnessOptions freshness       = FreshnessOptions.All,
            ImageContentOptions imageContent = ImageContentOptions.All,
            ImageTypeOptions imageType       = ImageTypeOptions.All,
            LicenseOptions license           = LicenseOptions.All,
            SizeOptions size                 = SizeOptions.All,
            SafeSearchOptions safeSearch     = SafeSearchOptions.Off,
            List <ModulesRequestedOptions> modulesRequested = null,
            float cab            = 0f,
            float cal            = 0f,
            float car            = 0f,
            float cat            = 0f,
            int ct               = 0,
            string cc            = "",
            string id            = "",
            string imgUrl        = "",
            string insightsToken = "")
        {
            var url = GetImageInsightUrl(query, height, width, count, offset, languageCode, aspect, color,
                                         freshness, imageContent, imageType, license, size, safeSearch, modulesRequested, cab, cal,
                                         car, cat, ct, cc, id, imgUrl, insightsToken);

            var response = await RepositoryClient.SendPostMultiPartAsync(ApiKeys.BingSearch, url, "{}");

            return(JsonConvert.DeserializeObject <ImageInsightResponse>(response));
        }
Beispiel #4
0
 /// <inheritdoc />
 public Task <IEnumerable <Request> > GetAllRequestsAsync(CancellationToken cancellationToken,
                                                          SizeOptions sizeOptions = null,
                                                          ExpirationDateOptions expirationDateOptions = null,
                                                          IDomainId domainIdOption          = null,
                                                          RetrievalOptions retrievalOptions = RetrievalOptions.ExcludeSoftDeleted,
                                                          RequestStatus?requestStatus       = null)
 {
     return(RetryAsync(
                nameof(ISymbolServiceClient.GetAllRequestsAsync),
                (client, ct) => client.GetAllRequestsAsync(ct, sizeOptions, expirationDateOptions, domainIdOption, retrievalOptions, requestStatus),
                cancellationToken));
 }
Beispiel #5
0
 /// <inheritdoc />
 public Task <IEnumerable <Request> > GetRequestPaginatedAsync(
     String continueFromRequestId,
     int pageSize,
     CancellationToken cancellationToken,
     SizeOptions sizeOptions = null,
     ExpirationDateOptions expirationDateOptions = null,
     IDomainId domainIdOption          = null,
     RetrievalOptions retrievalOptions = RetrievalOptions.ExcludeSoftDeleted,
     RequestStatus?requestStatus       = null)
 {
     return(RetryAsync(
                nameof(ISymbolServiceClient.GetRequestPaginatedAsync),
                (client, ct) => client.GetRequestPaginatedAsync(continueFromRequestId, pageSize, ct, sizeOptions, expirationDateOptions, domainIdOption, retrievalOptions, requestStatus),
                cancellationToken));
 }
 /// <inheritdoc />
 public Task <IEnumerable <DropItem> > ListAsync(
     string dropNamePrefix,
     PathOptions pathOptions,
     bool includeNonFinalizedDrops,
     CancellationToken cancellationToken,
     RetrievalOptions retrievalOptions,
     SizeOptions sizeOptions,
     ExpirationDateOptions expirationDateOptions,
     IDomainId domainId,
     int pageSize = -1,
     string continueFromDropName = null)
 {
     return(RetryAsync(
                nameof(IDropServiceClient.ListAsync),
                (client, ct) => client.ListAsync(dropNamePrefix, pathOptions, includeNonFinalizedDrops, ct, retrievalOptions, sizeOptions, expirationDateOptions, domainId, pageSize, continueFromDropName),
                cancellationToken));
 }
Beispiel #7
0
 public ChartConfiguration(ChartData data,
                           ChartAxis axis                 = null,
                           SizeOptions size               = null,
                           PaddingOptions padding         = null,
                           ColorOptions color             = null,
                           InteractionOptions interaction = null,
                           TransitionOptions transition   = null,
                           SubchartOptions subchart       = null,
                           ZoomOptions zoom               = null)
 {
     Data        = data;
     Axis        = axis;
     Size        = size;
     Padding     = padding;
     Color       = color;
     Interaction = interaction;
     Transition  = transition;
     Subchart    = subchart;
     Zoom        = zoom;
 }
        public virtual ImageInsightResponse GetImageInsights(
            string query                     = "",
            int height                       = 0,
            int width                        = 0,
            int count                        = 0,
            int offset                       = 0,
            string languageCode              = "",
            AspectOptions aspect             = AspectOptions.All,
            ColorOptions color               = ColorOptions.All,
            FreshnessOptions freshness       = FreshnessOptions.All,
            ImageContentOptions imageContent = ImageContentOptions.All,
            ImageTypeOptions imageType       = ImageTypeOptions.All,
            LicenseOptions license           = LicenseOptions.All,
            SizeOptions size                 = SizeOptions.All,
            SafeSearchOptions safeSearch     = SafeSearchOptions.Off,
            List <ModulesRequestedOptions> modulesRequested = null,
            float cab            = 0f,
            float cal            = 0f,
            float car            = 0f,
            float cat            = 0f,
            int ct               = 0,
            string cc            = "",
            string id            = "",
            string imgUrl        = "",
            string insightsToken = "")
        {
            try
            {
                var result = ImageSearchRepository.GetImageInsights(query, height, width, count, offset, languageCode, aspect, color, freshness, imageContent, imageType, license, size, safeSearch, modulesRequested, cab, cal, car, cat, ct, cc, id, imgUrl, insightsToken);

                return(result);
            }
            catch (Exception ex)
            {
                Logger.Error("ImageSearchService.GetImageInsights failed", this, ex);
            }

            return(null);
        }
 public virtual ImageInsightResponse GetImageInsights(
     string query                     = "",
     int height                       = 0,
     int width                        = 0,
     int count                        = 0,
     int offset                       = 0,
     string languageCode              = "",
     AspectOptions aspect             = AspectOptions.All,
     ColorOptions color               = ColorOptions.All,
     FreshnessOptions freshness       = FreshnessOptions.All,
     ImageContentOptions imageContent = ImageContentOptions.All,
     ImageTypeOptions imageType       = ImageTypeOptions.All,
     LicenseOptions license           = LicenseOptions.All,
     SizeOptions size                 = SizeOptions.All,
     SafeSearchOptions safeSearch     = SafeSearchOptions.Off,
     List <ModulesRequestedOptions> modulesRequested = null,
     float cab            = 0f,
     float cal            = 0f,
     float car            = 0f,
     float cat            = 0f,
     int ct               = 0,
     string cc            = "",
     string id            = "",
     string imgUrl        = "",
     string insightsToken = "")
 {
     return(PolicyService.ExecuteRetryAndCapture400Errors(
                "ImageSearchService.GetImageInsights",
                ApiKeys.BingSearchRetryInSeconds,
                () =>
     {
         var result = ImageSearchRepository.GetImageInsights(query, height, width, count, offset, languageCode, aspect, color, freshness, imageContent, imageType, license, size, safeSearch, modulesRequested, cab, cal, car, cat, ct, cc, id, imgUrl, insightsToken);
         return result;
     },
                null));
 }
Beispiel #10
0
 public SizeAttribute(string sizeCode, int defaultSize = 0, SizeOptions options = SizeOptions.None)
 {
     SizeCode = sizeCode;
     Options  = options;
     Size     = defaultSize;
 }
Beispiel #11
0
 public SizeAttribute(int size, SizeOptions options = SizeOptions.None)
 {
     Size    = size;
     Options = options;
 }
Beispiel #12
0
        protected virtual string GetImageInsightUrl(
            string query                     = "",
            int height                       = 0,
            int width                        = 0,
            int count                        = 0,
            int offset                       = 0,
            string languageCode              = "",
            AspectOptions aspect             = AspectOptions.All,
            ColorOptions color               = ColorOptions.All,
            FreshnessOptions freshness       = FreshnessOptions.All,
            ImageContentOptions imageContent = ImageContentOptions.All,
            ImageTypeOptions imageType       = ImageTypeOptions.All,
            LicenseOptions license           = LicenseOptions.All,
            SizeOptions size                 = SizeOptions.All,
            SafeSearchOptions safeSearch     = SafeSearchOptions.Off,
            List <ModulesRequestedOptions> modulesRequested = null,
            float cab            = 0f,
            float cal            = 0f,
            float car            = 0f,
            float cat            = 0f,
            int ct               = 0,
            string cc            = "",
            string id            = "",
            string imgUrl        = "",
            string insightsToken = "")
        {
            StringBuilder sb = new StringBuilder();

            sb.Append($"{imageSearchUrl}?q={query}");

            if (height > 0)
            {
                sb.Append($"&height={height}");
            }

            if (width > 0)
            {
                sb.Append($"&width={width}");
            }

            if (count > 0)
            {
                sb.Append($"&count={count}");
            }

            if (offset > 0)
            {
                sb.Append($"&offset={offset}");
            }

            if (!string.IsNullOrEmpty(languageCode))
            {
                sb.Append($"&mkt={languageCode}");
            }

            var aspectName = Enum.GetName(typeof(AspectOptions), aspect);

            if (aspectName != null && !aspectName.Equals("All"))
            {
                sb.Append($"&aspect={aspectName}");
            }

            var colorName = Enum.GetName(typeof(ColorOptions), color);

            if (colorName != null && !colorName.Equals("All"))
            {
                sb.Append($"&color={colorName}");
            }

            var freshnessName = Enum.GetName(typeof(FreshnessOptions), freshness);

            if (freshnessName != null && !freshnessName.Equals("All"))
            {
                sb.Append($"&freshness={freshnessName}");
            }

            var imageContentName = Enum.GetName(typeof(ImageContentOptions), imageContent);

            if (imageContentName != null && !imageContentName.Equals("All"))
            {
                sb.Append($"&imageContent={imageContentName}");
            }

            var imageTypeName = Enum.GetName(typeof(ImageTypeOptions), imageType);

            if (imageTypeName != null && !imageTypeName.Equals("All"))
            {
                sb.Append($"&imageType={imageTypeName}");
            }

            var licenseName = Enum.GetName(typeof(LicenseOptions), license);

            if (licenseName != null && !licenseName.Equals("All"))
            {
                sb.Append($"&license={licenseName}");
            }

            var sizeName = Enum.GetName(typeof(SizeOptions), size);

            if (sizeName != null && !sizeName.Equals("All"))
            {
                sb.Append($"&size={sizeName}");
            }

            var safeSearchName = Enum.GetName(typeof(SafeSearchOptions), safeSearch);

            if (safeSearchName != null && !safeSearchName.Equals("All"))
            {
                sb.Append($"&safeSearch={safeSearchName}");
            }

            StringBuilder mod = new StringBuilder();

            if (modulesRequested != null)
            {
                foreach (var m in modulesRequested)
                {
                    if (mod.Length > 0)
                    {
                        mod.Append(",");
                    }

                    mod.Append(Enum.GetName(typeof(ModulesRequestedOptions), m));
                }
                sb.Append($"&modulesRequested={mod}");
            }

            if (cab > 0f)
            {
                sb.Append($"&cab={cab}");
            }

            if (cal > 0f)
            {
                sb.Append($"&cal={cal}");
            }

            if (car > 0f)
            {
                sb.Append($"&car={car}");
            }

            if (cat > 0f)
            {
                sb.Append($"&cat={cat}");
            }

            if (ct > 0)
            {
                sb.Append($"&ct={ct}");
            }

            if (!string.IsNullOrEmpty(cc))
            {
                sb.Append($"&cc={cc}");
            }

            if (!string.IsNullOrEmpty(id))
            {
                sb.Append($"&id={id}");
            }

            if (!string.IsNullOrEmpty(imgUrl))
            {
                sb.Append($"&imgUrl={HttpUtility.UrlEncode(imgUrl)}");
            }

            if (!string.IsNullOrEmpty(insightsToken))
            {
                sb.Append($"&insightsToken={insightsToken}");
            }

            return(sb.ToString());
        }
Beispiel #13
0
 public SizeAttribute(int size, SizeOptions options = SizeOptions.None)
 {
     Size = size;
       Options = options;
 }
Beispiel #14
0
 /// <inheritdoc />
 public Task <IEnumerable <DropItem> > ListAsync(string dropNamePrefix, PathOptions pathOptions, bool includeNonFinalizedDrops, CancellationToken cancellationToken, RetrievalOptions retrievalOptions, SizeOptions sizeOptions, ExpirationDateOptions expirationDateOptions)
 {
     return(RetryAsync(
                nameof(IDropServiceClient.ListAsync),
                (client, ct) => client.ListAsync(dropNamePrefix, pathOptions, includeNonFinalizedDrops, ct, retrievalOptions, sizeOptions, expirationDateOptions),
                cancellationToken));
 }
Beispiel #15
0
 public static T SetSize <T>(this T obj, SizeOptions sizeOption) where T : ISizeProperty
 {
     obj.Size = sizeOption;
     return(obj);
 }
Beispiel #16
0
 public SizeAttribute(string sizeCode, int defaultSize = 0, SizeOptions options = SizeOptions.None)
 {
     SizeCode = sizeCode;
       Options = options;
       Size = defaultSize;
 }
 /// <inheritdoc />
 public Task <IEnumerable <Request> > GetAllRequestsAsync(CancellationToken cancellationToken, SizeOptions sizeOptions = null, ExpirationDateOptions expirationDateOptions = null, IDomainId domainIdOption = null)
 {
     return(RetryAsync(
                nameof(ISymbolServiceClient.GetAllRequestsAsync),
                (client, ct) => client.GetAllRequestsAsync(ct, sizeOptions, expirationDateOptions, domainIdOption),
                cancellationToken));
 }
 Task <IEnumerable <DropItem> > IDropServiceClient.ListAsync(string dropNamePrefix, PathOptions pathOptions, bool includeNonFinalizedDrops, CancellationToken cancellationToken, RetrievalOptions retrievalOptions, SizeOptions sizeOptions, ExpirationDateOptions expirationDateOptions, IDomainId domainId, int pageSize, string continueFromDropName)
 {
     throw new NotImplementedException();
 }
Beispiel #19
0
 /// <inheritdoc />
 public Task <IEnumerable <Request> > GetRequestPaginatedAsync(string continueFromRequestId, int pageSize, CancellationToken cancellationToken, SizeOptions sizeOptions, ExpirationDateOptions expirationDateOptions)
 {
     return(RetryAsync(
                nameof(ISymbolServiceClient.GetRequestPaginatedAsync),
                (client, ct) => client.GetRequestPaginatedAsync(continueFromRequestId, pageSize, ct, sizeOptions, expirationDateOptions),
                cancellationToken));
 }