Beispiel #1
0
        string GetFilesForRemote(IEnumerable <string> remoteAssetPaths, BundleState state)
        {
            var sb = new StringBuilder();

            foreach (var uri in remoteAssetPaths)
            {
                sb.Append(FillTemplate(state, uri));
            }

            return(sb.ToString());
        }
Beispiel #2
0
        public string RenderCached(string name)
        {
            bundleState = GetCachedBundleState(name);
            var content = CacheRenderer.Get(CachePrefix, name);

            if (content == null)
            {
                AsCached(name, bundleState.Path);
                return(CacheRenderer.Get(CachePrefix, name));
            }
            return(content);
        }
Beispiel #3
0
        string GetAdditionalAttributes(BundleState state)
        {
            var result = new StringBuilder();

            foreach (var attribute in state.Attributes)
            {
                result.Append(attribute.Key);
                result.Append("=\"");
                result.Append(attribute.Value);
                result.Append("\" ");
            }
            return(result.ToString());
        }
Beispiel #4
0
 protected BundleBase(IFileWriterFactory fileWriterFactory, IFileReaderFactory fileReaderFactory, IDebugStatusReader debugStatusReader, IDirectoryWrapper directoryWrapper, IHasher hasher, IBundleCache bundleCache)
 {
     this.fileWriterFactory = fileWriterFactory;
     this.fileReaderFactory = fileReaderFactory;
     this.debugStatusReader = debugStatusReader;
     this.directoryWrapper  = directoryWrapper;
     this.hasher            = hasher;
     bundleState            = new BundleState
     {
         DebugPredicate = Configuration.Instance.DefaultDebugPredicate(),
         ShouldRenderOnlyIfOutputFileIsMissing = false,
         HashKeyName = "r"
     };
     this.bundleCache = bundleCache;
 }
Beispiel #5
0
        public string RenderNamed(string name)
        {
            bundleState = GetCachedBundleState(name);
            //TODO: this sucks
            // Revisit https://github.com/jetheredge/SquishIt/pull/155 and https://github.com/jetheredge/SquishIt/issues/183
            //hopefully we can find a better way to satisfy both of these requirements
            var fullName = (BaseOutputHref ?? "") + CachePrefix + name;
            var content  = bundleCache.GetContent(fullName);

            if (content == null)
            {
                AsNamed(name, bundleState.Path);
                return(bundleCache.GetContent(CachePrefix + name));
            }
            return(content);
        }
Beispiel #6
0
        /// <summary>
        /// Render cached 'raw' bundle content.
        /// </summary>
        /// <param name="bundleName">String representation of content according to cache.</param>
        /// <returns></returns>
        public string RenderCachedRawContent(string bundleName)
        {
            var cacheKey = CachePrefix + "_raw_" + bundleName;

            var output = rawContentCache.GetContent(cacheKey);

            if (output == null)
            {
                bundleState = rawContentBundleStateCache[cacheKey];
                if (bundleState == null)
                {
                    throw new InvalidOperationException(string.Format("No cached bundle state named {0} was found.", bundleName));
                }
                output = RenderRawContent(bundleName);
            }
            return(output);
        }
Beispiel #7
0
 public string RenderCachedAssetTag(string name)
 {
     bundleState = GetCachedBundleState(name);
     return(Render(null, name, new CacheRenderer(CachePrefix, name)));
 }
Beispiel #8
0
 string FillTemplate(BundleState bundleState, string path)
 {
     return(string.Format(Template, GetAdditionalAttributes(bundleState), path));
 }