Beispiel #1
0
        protected IEnumerable <Uri> GetTransformedUrls()
        {
            return(_urls.Cast <string>().Select(s =>
            {
                var url = s;
                if (string.IsNullOrEmpty(url))
                {
                    return null;
                }

                if (url.Contains("$("))
                {
                    url = GlobalVariables.Aggregate(url, (current, variable) => current.Replace("$(" + variable.Key + ")", variable.Value));
                }
                if (!url.StartsWith("http://") && !url.StartsWith("https://"))
                {
                    url = "http://" + url;
                }

                if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
                {
                    return new Uri(url, UriKind.Absolute);
                }
                if (Uri.IsWellFormedUriString(url, UriKind.Relative))
                {
                    return new Uri(url, UriKind.Relative);
                }

                return null;
            }).Where(s => s != null));
        }