Beispiel #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);
        }
Beispiel #2
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)
                .AppendDictionary(request.CustomParameters);

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

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

            return("/");
        }
Beispiel #4
0
        private static string GetRepeatMethod(XpoUrlRequest request)
        {
            if (request.ResizeMethod == XpoUrlResizeMethods.Repeat && request.FileType == XpoUrlFileTypes.Design)
            {
                return "1";
            }

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

            return("");
        }
        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");
        }
Beispiel #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");
        }
        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;
        }
        /// <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));
        }
Beispiel #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("");
        }
Beispiel #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");
        }
Beispiel #12
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 "";
        }
Beispiel #13
0
 public XpoUrlParts GetUrlParts(XpoUrlRequest request)
 {
     throw new NotImplementedException("Cannot get URL parts for the XPO V1 implementation");
 }
Beispiel #14
0
 private static string GetCachingMethod(XpoUrlRequest request)
 {
     return(request.Caching ? "Default" : "No");
 }
        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");
        }
Beispiel #16
0
 private static string GetCachingMethod(XpoUrlRequest request)
 {
     return request.Caching ? "Default" : "No";
 }
 public XpoUrlParts GetUrlParts(XpoUrlRequest request)
 {
     throw new NotImplementedException("Cannot get URL parts for the XPO V1 implementation");
 }