示例#1
0
        private ImageFileInfo GetVariantImageFileInfo(int sequenceNumber, VariantImageQueryParam queryParam)
        {
            var imageFilePath = _damProviderConfigurationSection.VariantImageFilePathPattern
                                .Replace(ProductIdFieldName, queryParam.ProductId)
                                .Replace(VariantIdFieldName, queryParam.VariantId)
                                .Replace(ImageSizeFieldName, GetImageSizeAsFirstLetterNotation(queryParam.ImageSize))
                                .Replace(SequenceNumberFieldName, sequenceNumber.ToString())
                                .Replace(ImageTypeFieldName, ImageTypeExtension);
            var result = new ImageFileInfo
            {
                Sequence  = sequenceNumber,
                ImageSize = queryParam.ImageSize,
                Location  = GetImageEndpoint(queryParam.ScopeId, imageFilePath)
            };

            return(result);
        }
示例#2
0
        public Task <IList <Dictionary <ImageSize, ImageFileInfo> > > GetVariantImagesLocationsAsync(VariantImageQueryParam queryParam)
        {
            IList <Dictionary <ImageSize, ImageFileInfo> > result = new List <Dictionary <ImageSize, ImageFileInfo> >();

            for (var imageSequenceNumber = 0; imageSequenceNumber < ImagesRetrievalLimit; imageSequenceNumber++)
            {
                var dictionary = new Dictionary <ImageSize, ImageFileInfo>();

                if (queryParam.ImageSize == ImageSize.All)
                {
                    var newQueryParam = new VariantImageQueryParam()
                    {
                        ImageSize = queryParam.ImageSize,
                        ProductId = queryParam.ProductId,
                        VariantId = queryParam.VariantId,
                        ScopeId   = queryParam.ScopeId
                    };

                    // Taking care of the small image size.
                    newQueryParam.ImageSize = ImageSize.Small;
                    var smallVariantImageFileInfo = GetVariantImageFileInfo(imageSequenceNumber, newQueryParam);
                    dictionary.Add(ImageSize.Small, smallVariantImageFileInfo);

                    // Taking care of the medium image size.
                    newQueryParam.ImageSize = ImageSize.Medium;
                    var mediumVariantImageFileInfo = GetVariantImageFileInfo(imageSequenceNumber, newQueryParam);
                    dictionary.Add(ImageSize.Medium, mediumVariantImageFileInfo);

                    // Taking care of the large image size.
                    newQueryParam.ImageSize = ImageSize.Large;
                    var largeVariantImageFileInfo = GetVariantImageFileInfo(imageSequenceNumber, newQueryParam);
                    dictionary.Add(ImageSize.Large, largeVariantImageFileInfo);
                }
                else
                {
                    // Simply add the product image at the specified image size.
                    var variantImageFileInfo = GetVariantImageFileInfo(imageSequenceNumber, queryParam);
                    dictionary.Add(queryParam.ImageSize, variantImageFileInfo);
                }

                result.Add(dictionary);
            }
            return(Task.FromResult(result));
        }