コード例 #1
0
        /// <summary>
        /// Adds the given url to the ResourceDefinition and appends a cacheBuster to it.
        /// </summary>
        /// <param name="self">The ResourceDefinition file to add the url to.</param>
        /// <param name="url">The URL to add to the ResourceDefinition.</param>
        /// <param name="debugUrl">The url to use in debug mode. Use this to specify an unminified, unobfuscated version of your resource.</param>
        /// <param name="frequent">If true, the cacheBuster will be updated each minute. Otherwise it'll be changed daily.</param>
        public static ResourceDefinition SetUrlWithCacheBuster(this ResourceDefinition self, string url, string debugUrl = null, bool frequent = false)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                throw new ArgumentNullException("url");
            }

            var cacheBustQueryString = frequent
                ? (long)new TimeSpan(DateTime.Now.Ticks - DateTime.MinValue.Ticks).TotalMinutes
                : DateTime.Today.Ticks;

            var urlWithCacheBuster = string.Format("{0}?{1}", url, cacheBustQueryString);

            return(!string.IsNullOrWhiteSpace(debugUrl)
                ? self.SetUrl(urlWithCacheBuster, string.Format("{0}?{1}", debugUrl, cacheBustQueryString))
                : self.SetUrl(urlWithCacheBuster));
        }
コード例 #2
0
ファイル: ResourceUtil.cs プロジェクト: showmap/smartwalk
        public static ResourceDefinition SetVersionUrl(
            this ResourceDefinition definition,
            string url,
            string urlDebug)
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException("url");
            }

            if (definition.Version != null)
            {
                url += "?ver=" + definition.Version;

                if (urlDebug != null)
                {
                    urlDebug += "?ver=" + definition.Version;
                }
            }

            return(definition.SetUrl(url, urlDebug));
        }
コード例 #3
0
 public static void SetUrlProtocolRelative(this ResourceDefinition resource, Uri url)
 {
     resource.SetUrl(url.ToStringWithoutScheme());
 }