コード例 #1
0
        public static StringBuilder AppendRequest(this StringBuilder stringBuilder, XpoUrlRequest request)
        {
            stringBuilder
            .Append("?1=1")
            .Append(Width, (request.Width == 0) ? -1 : request.Width)     // Safety (0 is the default value)
            .Append(BackgroundColor, request.BackgroundColor)
            .Append(Caching, GetCachingMethod(request))
            .Append(Height, request.Height)
            .Append(DesignCaching, request.DesignCaching)
            .Append(ResizeMethod, GetResizeMethod(request))
            .Append(TextureRepeat, GetRepeatMethod(request))
            .Append(OutputQuality, request.OutputQuality)
            .Append(ImageType, GetFormat(request.ImageType))
            .Append(SceneThumbnailObjectNumber, request.SceneThumbnailObjectNumber)
            .Append(HighlightObject, request.HighlightObject)
            .Append(Watermark, request.WatermarkImage)
            .Append(Frame, request.Frame)
            .Append(RenderMode, request.SceneRenderMode)
            .Append(FastRender, request.FastRender)
            .AppendDictionary(request.CustomParameters);

            if (request is XpoCoordinatesUrlRequest)
            {
                stringBuilder.Append(Coords, true);
            }

            return(stringBuilder);
        }
コード例 #2
0
ファイル: GeneralKeys.cs プロジェクト: BrandonMathis/xpoapi
        public static StringBuilder AppendRequest(this StringBuilder stringBuilder, XpoUrlRequest request)
        {
            stringBuilder
                .Append("?1=1")
                .Append(Width, (request.Width == 0) ? -1 : request.Width) // Safety (0 is the default value)
                .Append(BackgroundColor, request.BackgroundColor)
                .Append(Caching, GetCachingMethod(request))
                .Append(Height, request.Height)
                .Append(DesignCaching, request.DesignCaching)
                .Append(ResizeMethod, GetResizeMethod(request))
                .Append(TextureRepeat, GetRepeatMethod(request))
                .Append(OutputQuality, request.OutputQuality)
                .Append(ImageType, GetFormat(request.ImageType))
                .Append(SceneThumbnailObjectNumber, request.SceneThumbnailObjectNumber)
                .Append(HighlightObject, request.HighlightObject)
                .Append(Watermark, request.WatermarkImage)
                .Append(Frame, request.Frame)
                .AppendDictionary(request.CustomParameters);

            if (request is XpoCoordinatesUrlRequest)
            {
                stringBuilder.Append(Coords, true);
            }

            return stringBuilder;
        }
コード例 #3
0
        private string GetXpoBaseUrl(XpoUrlRequest urlRequest)
        {
            if (urlRequest != null && !string.IsNullOrEmpty(urlRequest.AbsoluteUrl))
            {
                return(urlRequest.AbsoluteUrl.EndsWith("/") ? urlRequest.AbsoluteUrl : urlRequest.AbsoluteUrl + "/");
            }

            return("/");
        }
コード例 #4
0
ファイル: GeneralKeys.cs プロジェクト: BrandonMathis/xpoapi
        private static string GetRepeatMethod(XpoUrlRequest request)
        {
            if (request.ResizeMethod == XpoUrlResizeMethods.Repeat && request.FileType == XpoUrlFileTypes.Design)
            {
                return "1";
            }

            return "";
        }
コード例 #5
0
        private static string GetRepeatMethod(XpoUrlRequest request)
        {
            if (request.ResizeMethod == XpoUrlResizeMethods.Repeat && request.FileType == XpoUrlFileTypes.Design)
            {
                return("1");
            }

            return("");
        }
コード例 #6
0
        public string GetUrl(XpoUrlRequest request)
        {
            if (request is XpoImageUrlRequest)
                return GetUrl(request as XpoImageUrlRequest);

            if (request is XpoCoordinatesUrlRequest)
                return GetUrl(request as XpoCoordinatesUrlRequest);

            throw new NotSupportedException("Input type is not recognized");
        }
コード例 #7
0
        public string GetUrl(XpoUrlRequest request)
        {
            if (request is XpoImageUrlRequest)
            {
                return(GetUrl(request as XpoImageUrlRequest));
            }

            if (request is XpoCoordinatesUrlRequest)
            {
                return(GetUrl(request as XpoCoordinatesUrlRequest));
            }

            throw new NotSupportedException("Input type is not recognized");
        }
コード例 #8
0
        public FluentXpoUrlGenerator(IXpoUrlGenerator generator, XpoUrlRequest request)
        {
            if (generator == null)
            {
                throw new ArgumentNullException("generator");
            }

            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            this.generator = generator;
            this.request   = request;
        }
コード例 #9
0
        /// <summary>
        /// Ensures the type of a request
        /// </summary>
        private static TUrlType EnsureUrlType <TUrlType>(XpoUrlRequest urlRequest)
            where TUrlType : XpoUrlRequest
        {
            if (urlRequest == null)
            {
                throw new ArgumentNullException("urlRequest", "Cannot use this class without an instance of the correct URL request.");
            }

            if (urlRequest is TUrlType)
            {
                return(urlRequest as TUrlType);
            }

            throw new InvalidCastException(
                      string.Format("Cannot cast {0} to {1}. Are you using the correct URL type?",
                                    urlRequest.GetType().Name,
                                    typeof(TUrlType).Name));
        }
コード例 #10
0
        private static string GetResizeMethod(XpoUrlRequest request)
        {
            switch (request.ResizeMethod)
            {
            case XpoUrlResizeMethods.KeepAspectMax:
                return("max");

            case XpoUrlResizeMethods.Crop:
                return("crop");

            case XpoUrlResizeMethods.Stretch:
                return("stretch");

            case XpoUrlResizeMethods.Canvas:
                return("canvas");
            }

            return("");
        }
コード例 #11
0
        private string GetXpoBaseUrl(XpoUrlRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            if (string.IsNullOrWhiteSpace(request.AbsoluteUrl))
            {
                throw new InvalidOperationException("Cannot use the XPO V1 implementation without supplying a base URL (AbsoluteURL property in the request)");
            }

            var uri = default(Uri);

            if (Uri.TryCreate(request.AbsoluteUrl, UriKind.Absolute, out uri))
            {
                return(request.AbsoluteUrl);
            }

            throw new InvalidOperationException("Could not use the supplied AbsoluteURL because it is not valid");
        }
コード例 #12
0
ファイル: GeneralKeys.cs プロジェクト: BrandonMathis/xpoapi
        private static string GetResizeMethod(XpoUrlRequest request)
        {
            switch (request.ResizeMethod)
            {
                case XpoUrlResizeMethods.KeepAspectMax:
                    return "max";
                case XpoUrlResizeMethods.Crop:
                    return "crop";
                case XpoUrlResizeMethods.Stretch:
                    return "stretch";
                case XpoUrlResizeMethods.Canvas:
                    return "canvas";
            }

            return "";
        }
コード例 #13
0
 public XpoUrlParts GetUrlParts(XpoUrlRequest request)
 {
     throw new NotImplementedException("Cannot get URL parts for the XPO V1 implementation");
 }
コード例 #14
0
 private static string GetCachingMethod(XpoUrlRequest request)
 {
     return(request.Caching ? "Default" : "No");
 }
コード例 #15
0
        private string GetXpoBaseUrl(XpoUrlRequest request)
        {
            if (request == null)
                throw new ArgumentNullException("request");

            if(string.IsNullOrWhiteSpace(request.AbsoluteUrl))
                throw new InvalidOperationException("Cannot use the XPO V1 implementation without supplying a base URL (AbsoluteURL property in the request)");

            var uri = default(Uri);

            if (Uri.TryCreate(request.AbsoluteUrl, UriKind.Absolute, out uri))
            {
                return request.AbsoluteUrl;
            }

            throw new InvalidOperationException("Could not use the supplied AbsoluteURL because it is not valid");
        }
コード例 #16
0
ファイル: GeneralKeys.cs プロジェクト: BrandonMathis/xpoapi
 private static string GetCachingMethod(XpoUrlRequest request)
 {
     return request.Caching ? "Default" : "No";
 }
コード例 #17
0
 public XpoUrlParts GetUrlParts(XpoUrlRequest request)
 {
     throw new NotImplementedException("Cannot get URL parts for the XPO V1 implementation");
 }