예제 #1
0
        static CSSPrimitiveValue Image(List <CSSValue> arguments)
        {
            if (arguments.Count == 0)
            {
                return(null);
            }

            var imageList = new List <Url>();

            foreach (var argument in arguments)
            {
                var uri = argument.ToUri();

                if (uri == null)
                {
                    var s = argument.ToCssString();

                    if (s != null)
                    {
                        uri = new CssUrl(s);
                    }
                    else
                    {
                        return(null);
                    }
                }

                imageList.Add(new Url(uri));
            }

            return(new CSSPrimitiveValue(UnitType.ImageList, new CssImages(imageList)));
        }
        private IReadOnlyCollection <CssUrl> ParseUrls(string localCssFilePath, string cssFileWebUrl, string cssContent)
        {
            // We expcet URLs in the format url(/.resources/xxx/webresources/resources/slick.eot?#iefix)
            // We also remove URLs with 'data', as they are not real files
            var urlRegex = new Regex(@"(url\()(?<urlVal>.+?)(\))");
            var matches  = urlRegex.Matches(cssContent);
            var result   = new List <CssUrl>();

            matches.ForEach(
                match =>
            {
                var relativeWebUrl = match.Groups["urlVal"].Value;
                if (relativeWebUrl.Contains("data:", StringComparison.OrdinalIgnoreCase))
                {
                    return;
                }

                var absoluteWebUrl    = _pathAligner.AlignUrl(cssFileWebUrl, relativeWebUrl);
                var localFullFileName = _pathAligner.AlignFilePath(localCssFilePath, relativeWebUrl);
                var url = new CssUrl(relativeWebUrl, localFullFileName, absoluteWebUrl);
                result.Add(url);
            });

            return(result);
        }
예제 #3
0
 public CSSPrimitiveValue(CssUrl url)
     : this(UnitType.Uri, url)
 {
 }