コード例 #1
0
        public ImageOptimizationResponse ProcessImage(ImageOptimizationRequest imageOptimizationRequest)
        {
            if (imageOptimizationRequest == null)
            {
                return new ImageOptimizationResponse();
            }

            var smushItRequest = new SmushItRequest
                                     {
                                         ImageUrl = imageOptimizationRequest.ImageUrl
                                     };
            SmushItResponse smushItResponse = this._smushItProxy.ProcessImage(smushItRequest);

            return smushItResponse.ConvertToResponse();
        }
コード例 #2
0
ファイル: SmushItProxy.cs プロジェクト: ajuris/opensource
        public SmushItResponse ProcessImage(SmushItRequest smushItRequest)
        {
            string jsonResponse = string.Empty;

            string endpoint = this.BuildUrl(smushItRequest.ImageUrl);

            try
            {
                jsonResponse = this._webClient.DownloadString(endpoint);
            }
            catch (WebException exception)
            {
                throw new WebException(exception.Message);
            }

            if (!string.IsNullOrEmpty(jsonResponse))
            {
                return this._javaScriptSerializer.Deserialize<SmushItResponse>(jsonResponse);
            }

            return new SmushItResponse { Src = smushItRequest.ImageUrl };
        }