Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Initial commit

  • Loading branch information...
DavidZidar committed May 21, 2012
0 parents commit f99097d9c5e1d3ac8da7be5d2dec43f1e8a439b7
Showing with 22,727 additions and 0 deletions.
  1. +49 −0 .gitattributes
  2. +14 −0 .gitignore
  3. +15 −0 Build.ps1
  4. +30 −0 NuGet/CacheTag.nuspec
  5. +172 −0 README.md
  6. +6 −0 Source/.nuget/NuGet.Config
  7. BIN Source/.nuget/NuGet.exe
  8. +52 −0 Source/.nuget/NuGet.targets
  9. +6 −0 Source/BuildScript.targets
  10. +28 −0 Source/CacheTag.Core/Cache/HttpRuntimeCacheProvider.cs
  11. +12 −0 Source/CacheTag.Core/Cache/ICacheProvider.cs
  12. +115 −0 Source/CacheTag.Core/CacheTag.Core.csproj
  13. +70 −0 Source/CacheTag.Core/Configuration/Container.cs
  14. +9 −0 Source/CacheTag.Core/Configuration/IUrlResolver.cs
  15. +9 −0 Source/CacheTag.Core/Configuration/RuntimeMode.cs
  16. +33 −0 Source/CacheTag.Core/Configuration/Settings.cs
  17. +27 −0 Source/CacheTag.Core/Extensions/HashAlgorithmExtensions.cs
  18. +56 −0 Source/CacheTag.Core/Extensions/ResourceExtensions.cs
  19. +33 −0 Source/CacheTag.Core/Extensions/StreamExtensions.cs
  20. +59 −0 Source/CacheTag.Core/Filesystem/DefaultFileProvider.cs
  21. +14 −0 Source/CacheTag.Core/Filesystem/IFileProvider.cs
  22. +43 −0 Source/CacheTag.Core/Filesystem/PhysicalFileProvider.cs
  23. +38 −0 Source/CacheTag.Core/Filesystem/RemoteFileProvider.cs
  24. +41 −0 Source/CacheTag.Core/Filesystem/VirtualPathFileProvider.cs
  25. +8 −0 Source/CacheTag.Core/ICacheTagModule.cs
  26. +60 −0 Source/CacheTag.Core/Network/HttpUtility.cs
  27. +10 −0 Source/CacheTag.Core/Network/RemoteFile.cs
  28. +32 −0 Source/CacheTag.Core/Properties/AssemblyInfo.cs
  29. +71 −0 Source/CacheTag.Core/Resources/BaseFileResource.cs
  30. +24 −0 Source/CacheTag.Core/Resources/BaseSnippet.cs
  31. +9 −0 Source/CacheTag.Core/Resources/Html/IHtmlRenderer.cs
  32. +19 −0 Source/CacheTag.Core/Resources/Html/ImageHtmlRenderer.cs
  33. +18 −0 Source/CacheTag.Core/Resources/Html/ScriptHtmlRenderer.cs
  34. +18 −0 Source/CacheTag.Core/Resources/Html/StyleHtmlRenderer.cs
  35. +7 −0 Source/CacheTag.Core/Resources/IPlainTextResource.cs
  36. +14 −0 Source/CacheTag.Core/Resources/IResource.cs
  37. +9 −0 Source/CacheTag.Core/Resources/IResourceCompiler.cs
  38. +12 −0 Source/CacheTag.Core/Resources/IResourceFactory.cs
  39. +9 −0 Source/CacheTag.Core/Resources/IResourceStorage.cs
  40. +9 −0 Source/CacheTag.Core/Resources/Images/IImageResource.cs
  41. +73 −0 Source/CacheTag.Core/Resources/Images/ImageFile.cs
  42. +27 −0 Source/CacheTag.Core/Resources/Images/ImageList.cs
  43. +13 −0 Source/CacheTag.Core/Resources/PassThroughCompiler.cs
  44. +24 −0 Source/CacheTag.Core/Resources/PlainTextFileResource.cs
  45. +42 −0 Source/CacheTag.Core/Resources/ResourceFactory.cs
  46. +6 −0 Source/CacheTag.Core/Resources/Scripts/IScriptResource.cs
  47. +17 −0 Source/CacheTag.Core/Resources/Scripts/ScriptFile.cs
  48. +24 −0 Source/CacheTag.Core/Resources/Scripts/ScriptList.cs
  49. +21 −0 Source/CacheTag.Core/Resources/Scripts/ScriptSnippet.cs
  50. +29 −0 Source/CacheTag.Core/Resources/StaticResourceStorage.cs
  51. +40 −0 Source/CacheTag.Core/Resources/StringBuilderCompiler.cs
  52. +6 −0 Source/CacheTag.Core/Resources/Styles/IStyleResource.cs
  53. +17 −0 Source/CacheTag.Core/Resources/Styles/StyleFile.cs
  54. +24 −0 Source/CacheTag.Core/Resources/Styles/StyleList.cs
  55. +21 −0 Source/CacheTag.Core/Resources/Styles/StyleSnippet.cs
  56. +38 −0 Source/CacheTag.Core/Startup.cs
  57. +5 −0 Source/CacheTag.Core/packages.config
  58. +58 −0 Source/CacheTag.Essentials.sln
  59. +113 −0 Source/CacheTag.Module.AjaxMin/AjaxMinResourceCompiler.cs
  60. +73 −0 Source/CacheTag.Module.AjaxMin/CacheTag.Module.AjaxMin.csproj
  61. +23 −0 Source/CacheTag.Module.AjaxMin/ModuleConfiguration.cs
  62. +32 −0 Source/CacheTag.Module.AjaxMin/Properties/AssemblyInfo.cs
  63. +4 −0 Source/CacheTag.Module.AjaxMin/packages.config
  64. +76 −0 Source/CacheTag.Module.DotLess/CacheTag.Module.DotLess.csproj
  65. +29 −0 Source/CacheTag.Module.DotLess/DotlessFileProvider.cs
  66. +99 −0 Source/CacheTag.Module.DotLess/DotlessParser.cs
  67. +12 −0 Source/CacheTag.Module.DotLess/DotlessStyle.cs
  68. +20 −0 Source/CacheTag.Module.DotLess/ModuleConfiguration.cs
  69. +10 −0 Source/CacheTag.Module.DotLess/ParseResult.cs
  70. +32 −0 Source/CacheTag.Module.DotLess/Properties/AssemblyInfo.cs
  71. +4 −0 Source/CacheTag.Module.DotLess/packages.config
  72. +76 −0 Source/CacheTag.Module.SassAndCoffee/CacheTag.Module.SassAndCoffee.csproj
  73. +30 −0 Source/CacheTag.Module.SassAndCoffee/CoffeeFileProvider.cs
  74. +12 −0 Source/CacheTag.Module.SassAndCoffee/CoffeeScript.cs
  75. +20 −0 Source/CacheTag.Module.SassAndCoffee/ModuleConfiguration.cs
  76. +32 −0 Source/CacheTag.Module.SassAndCoffee/Properties/AssemblyInfo.cs
  77. +5 −0 Source/CacheTag.Module.SassAndCoffee/packages.config
  78. +84 −0 Source/CacheTag.Mvc/CacheTag.Mvc.csproj
  79. +18 −0 Source/CacheTag.Mvc/CacheTagController.cs
  80. +23 −0 Source/CacheTag.Mvc/Extensions/ResourceExtensions.cs
  81. +21 −0 Source/CacheTag.Mvc/HtmlHelpers/ImageHelpers.cs
  82. +39 −0 Source/CacheTag.Mvc/HtmlHelpers/InternalResourceHelpers.cs
  83. +50 −0 Source/CacheTag.Mvc/HtmlHelpers/ReferenceScriptHelpers.cs
  84. +30 −0 Source/CacheTag.Mvc/HtmlHelpers/RenderScriptHelpers.cs
  85. +30 −0 Source/CacheTag.Mvc/HtmlHelpers/RenderStyleHelpers.cs
  86. +19 −0 Source/CacheTag.Mvc/HttpModule.cs
  87. +17 −0 Source/CacheTag.Mvc/ModuleConfiguration.cs
  88. +7 −0 Source/CacheTag.Mvc/MvcSettings.cs
  89. +13 −0 Source/CacheTag.Mvc/MvcUrlResolver.cs
  90. +32 −0 Source/CacheTag.Mvc/Properties/AssemblyInfo.cs
  91. +21 −0 Source/CacheTag.Mvc/Routing.cs
  92. +4 −0 Source/CacheTag.Mvc/packages.config
  93. +82 −0 Source/CacheTag.Tests/CacheTag.Tests.csproj
  94. +32 −0 Source/CacheTag.Tests/Properties/AssemblyInfo.cs
  95. +4 −0 Source/CacheTag.Tests/packages.config
  96. +62 −0 Source/CacheTag.sln
  97. +3 −0 Source/Example.Mvc/Content/app.less
  98. +11 −0 Source/Example.Mvc/Content/functions.less
  99. +40 −0 Source/Example.Mvc/Content/site.less
  100. +12 −0 Source/Example.Mvc/Controllers/HomeController.cs
  101. +100 −0 Source/Example.Mvc/Example.Mvc.Publish.xml
  102. +215 −0 Source/Example.Mvc/Example.Mvc.csproj
  103. +1 −0 Source/Example.Mvc/Global.asax
  104. +38 −0 Source/Example.Mvc/Global.asax.cs
  105. +32 −0 Source/Example.Mvc/Properties/AssemblyInfo.cs
  106. +4 −0 Source/Example.Mvc/Scripts/app.js
  107. +9,266 −0 Source/Example.Mvc/Scripts/jquery-1.7.1.js
  108. +4 −0 Source/Example.Mvc/Scripts/square.coffee
  109. +664 −0 Source/Example.Mvc/SyntaxHighlighter/scripts/XRegExp.js
  110. +49 −0 Source/Example.Mvc/SyntaxHighlighter/scripts/shBrushCSharp.js
  111. +53 −0 Source/Example.Mvc/SyntaxHighlighter/scripts/shBrushXml.js
  112. +1,714 −0 Source/Example.Mvc/SyntaxHighlighter/scripts/shCore.js
  113. +210 −0 Source/Example.Mvc/SyntaxHighlighter/styles/shCore.css
  114. +101 −0 Source/Example.Mvc/SyntaxHighlighter/styles/shThemeDefault.css
  115. +112 −0 Source/Example.Mvc/SyntaxHighlighter/styles/shThemeEclipse.css
  116. BIN Source/Example.Mvc/TwitterBootstrap/img/glyphicons-halflings-white.png
  117. BIN Source/Example.Mvc/TwitterBootstrap/img/glyphicons-halflings.png
  118. +90 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-alert.js
  119. +96 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-button.js
  120. +169 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-carousel.js
  121. +157 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-collapse.js
  122. +100 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-dropdown.js
  123. +218 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-modal.js
  124. +98 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-popover.js
  125. +151 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-scrollspy.js
  126. +135 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-tab.js
  127. +275 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-tooltip.js
  128. +61 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-transition.js
  129. +285 −0 Source/Example.Mvc/TwitterBootstrap/js/bootstrap-typeahead.js
  130. +33 −0 Source/Example.Mvc/TwitterBootstrap/less/accordion.less
  131. +58 −0 Source/Example.Mvc/TwitterBootstrap/less/alerts.less
  132. +62 −0 Source/Example.Mvc/TwitterBootstrap/less/bootstrap.less
  133. +24 −0 Source/Example.Mvc/TwitterBootstrap/less/breadcrumbs.less
  134. +191 −0 Source/Example.Mvc/TwitterBootstrap/less/button-groups.less
  135. +191 −0 Source/Example.Mvc/TwitterBootstrap/less/buttons.less
  136. +121 −0 Source/Example.Mvc/TwitterBootstrap/less/carousel.less
  137. +29 −0 Source/Example.Mvc/TwitterBootstrap/less/close.less
  138. +57 −0 Source/Example.Mvc/TwitterBootstrap/less/code.less
  139. +20 −0 Source/Example.Mvc/TwitterBootstrap/less/component-animations.less
  140. +143 −0 Source/Example.Mvc/TwitterBootstrap/less/dropdowns.less
  141. +584 −0 Source/Example.Mvc/TwitterBootstrap/less/forms.less
  142. +5 −0 Source/Example.Mvc/TwitterBootstrap/less/grid.less
  143. +22 −0 Source/Example.Mvc/TwitterBootstrap/less/hero-unit.less
  144. +55 −0 Source/Example.Mvc/TwitterBootstrap/less/labels-badges.less
  145. +17 −0 Source/Example.Mvc/TwitterBootstrap/less/layouts.less
  146. +631 −0 Source/Example.Mvc/TwitterBootstrap/less/mixins.less
  147. +90 −0 Source/Example.Mvc/TwitterBootstrap/less/modals.less
  148. +364 −0 Source/Example.Mvc/TwitterBootstrap/less/navbar.less
  149. +363 −0 Source/Example.Mvc/TwitterBootstrap/less/navs.less
  150. +36 −0 Source/Example.Mvc/TwitterBootstrap/less/pager.less
  151. +56 −0 Source/Example.Mvc/TwitterBootstrap/less/pagination.less
  152. +49 −0 Source/Example.Mvc/TwitterBootstrap/less/popovers.less
  153. +117 −0 Source/Example.Mvc/TwitterBootstrap/less/progress-bars.less
  154. +126 −0 Source/Example.Mvc/TwitterBootstrap/less/reset.less
  155. +26 −0 Source/Example.Mvc/TwitterBootstrap/less/responsive-1200px-min.less
  156. +149 −0 Source/Example.Mvc/TwitterBootstrap/less/responsive-767px-max.less
  157. +17 −0 Source/Example.Mvc/TwitterBootstrap/less/responsive-768px-979px.less
  158. +146 −0 Source/Example.Mvc/TwitterBootstrap/less/responsive-navbar.less
  159. +41 −0 Source/Example.Mvc/TwitterBootstrap/less/responsive-utilities.less
  160. +48 −0 Source/Example.Mvc/TwitterBootstrap/less/responsive.less
  161. +29 −0 Source/Example.Mvc/TwitterBootstrap/less/scaffolding.less
  162. +191 −0 Source/Example.Mvc/TwitterBootstrap/less/sprites.less
  163. +176 −0 Source/Example.Mvc/TwitterBootstrap/less/tables.less
  164. +47 −0 Source/Example.Mvc/TwitterBootstrap/less/thumbnails.less
  165. +35 −0 Source/Example.Mvc/TwitterBootstrap/less/tooltip.less
  166. +235 −0 Source/Example.Mvc/TwitterBootstrap/less/type.less
  167. +23 −0 Source/Example.Mvc/TwitterBootstrap/less/utilities.less
  168. +205 −0 Source/Example.Mvc/TwitterBootstrap/less/variables.less
  169. +27 −0 Source/Example.Mvc/TwitterBootstrap/less/wells.less
  170. +86 −0 Source/Example.Mvc/Views/Home/Index.cshtml
  171. +15 −0 Source/Example.Mvc/Views/Shared/Error.cshtml
  172. +44 −0 Source/Example.Mvc/Views/Shared/Footer.cshtml
  173. +17 −0 Source/Example.Mvc/Views/Shared/Navbar.cshtml
  174. +47 −0 Source/Example.Mvc/Views/Shared/_Layout.cshtml
  175. +58 −0 Source/Example.Mvc/Views/Web.config
  176. +3 −0 Source/Example.Mvc/Views/_ViewStart.cshtml
  177. +30 −0 Source/Example.Mvc/Web.Debug.config
  178. +31 −0 Source/Example.Mvc/Web.Release.config
  179. +54 −0 Source/Example.Mvc/Web.config
  180. +4 −0 Source/Example.Mvc/packages.config
@@ -0,0 +1,49 @@
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

*.jpg binary
*.png binary
*.gif binary

*.cs text=auto diff=csharp
*.vb text=auto
*.c text=auto
*.cpp text=auto
*.cxx text=auto
*.h text=auto
*.hxx text=auto
*.py text=auto
*.rb text=auto
*.java text=auto
*.html text=auto
*.htm text=auto
*.css text=auto
*.scss text=auto
*.sass text=auto
*.less text=auto
*.js text=auto
*.lisp text=auto
*.clj text=auto
*.sql text=auto
*.php text=auto
*.lua text=auto
*.m text=auto
*.asm text=auto
*.erl text=auto
*.fs text=auto
*.fsx text=auto
*.hs text=auto

*.csproj text=auto merge=union
*.vbproj text=auto merge=union
*.fsproj text=auto merge=union
*.dbproj text=auto merge=union
*.sln text=auto eol=crlf merge=union
@@ -0,0 +1,14 @@
^Build

bin/
obj/

_ReSharper\.[\w\d\.]+/
packages/

\.user$
\.suo$
\.sln\.cache$
\.dotCover$
\.docstates$
\.Publish\.xml$
@@ -0,0 +1,15 @@

param(
$Target = "Build",
$Configuration = "Release"
)

& Msbuild.exe `
/p:"Configuration=$Configuration" `
/p:"BuildTargetDir=..\..\Build" `
/t:$Target `
"Source\CacheTag.Essentials.sln"

if ($Target -eq 'Clean') {
rmdir -Recurse "Build"
}
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>CacheTag</id>
<version>1.0.0-beta2</version>
<authors>Steamcore</authors>
<owners>Steamcore</owners>
<projectUrl>http://cachetag.net/</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Simple and efficient JavaScript and CSS minification for ASP.NET MVC</description>
<releaseNotes>Performance fixes, remote file support, virtual path provider support</releaseNotes>
<dependencies>
<dependency id="AjaxMin" version="4.50.4504.34801" />
<dependency id="dotless" version="1.3.0.3" />
<dependency id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<dependency id="WebActivator" version="1.5" />
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Web" />
<frameworkAssembly assemblyName="System.Web.Mvc" />
</frameworkAssemblies>
<tags>js javascript css less dotless minify minification bundle bundling</tags>
</metadata>
<files>
<file src="..\Build\CacheTag.Core.dll" target="lib\net40" />
<file src="..\Build\CacheTag.Mvc.dll" target="lib\net40" />
<file src="..\Build\CacheTag.Module.AjaxMin.dll" target="lib\net40" />
<file src="..\Build\CacheTag.Module.DotLess.dll" target="lib\net40" />
</files>
</package>
172 README.md
@@ -0,0 +1,172 @@
CacheTag
========

Simple and efficient JavaScript and CSS minification for ASP.NET MVC

What it does
------------

CacheTag helps speed up your page load times in a number of ways:

- Reduces the number of HTTP requests by combining resources
- Makes resources quicker to download thanks to minification
- All resources are hashed, preventing clients from using old resources
- Since any change creates a new hash, resources can be cached aggressively

Compared to the competition
---------------------------

CacheTag provides a number of benefits compared to other similar frameworks.

- It's real easy to use, see the examples below
- It's flexible because it works with generic lists, no custom bundle classes
- It's faster because it only compiles resources when needed, even in debug mode
- Built to be extendable, use the source Luke!


How to get started
------------------

Add project references to **`CacheTag.Core`** and the modules you need, **`CacheTag.Mvc`** is a required module for now.

ASP.NET MVC Razor example
-------------------------

Try something like this in a view:

:::csharp
@Html.RenderStyles(new []
{
"~/CSS/Reset.css",
"~/CSS/Site.less"
})
@Html.RenderScripts(new []
{
"~/Scripts/jquery-1.7.1.js",
"~/Scripts/app.coffee"
})

You can also reference scripts or styles mid page like this:

@Html.ReferenceScript("~/Scripts/flot.js")

And then render all referenced scripts at once at the end of the page:

@Html.RenderReferencedScripts()

If you want, you can render scripts or styles inline as well, just add Inline to any render method.

Advanced examples
-----------------

Or you can build your scripts and styles manually:

:::csharp
var styleTags = new StyleList(new [] { "~/CSS/Reset.css", "~/CSS/Site.less" }).Compile().RenderHtml();
var scriptTags = new ScriptList(new [] { "~/Scripts/jquery-1.7.1.js", "~/Scripts/app.coffee" }).Compile().RenderHtml();

`ScriptList` and `StyleList` are just there for convenience, they only inherit from `List<IScriptList>` and `List<IStyleList>` respectively and do a bit of magic to resolve the type of resources based on the file name.

Since we are working with lists, it's easy to do what you want with it.

:::csharp
var scriptUrls =
new [] {
new ScriptFile("~/Scripts/jquery-1.7.1.js"),
new CoffeeScript("~/Scripts/app.coffee")
}.Compile().Select(x => x.Url);

The code snippet above will load two scripts, compile them if in release mode, and return a list of their resulting URLs. This might be useful for lazy loading scripts via yepnope or something similar.

Example of resulting HTML in release mode
-----------------------------------------

In release mode resources are combined, and minified if a minification module is referenced, to reduce the number of HTTP requests the client has to make.

<link rel="stylesheet" type="text/css" href="/_cachetag/e4dddf2cdd91d693e023cdc5dc0b56d8664766db" />
<script src="/_cachetag/80e9e6fc43c6644ea9badec99eb5c6cbec87c4b0" type="text/javascript"></script>
Example of resulting HTML in debug mode
---------------------------------------
When Web.config is configured for debug mode, resources ar linked individually with a SHA1-hash to ease debugging and prevent any browser cache issues.
:::html
<link rel="stylesheet" type="text/css" href="/CSS/Reset.css?f49b5e57ac2258bd3c980f30271554fa4731f26d" />
<link rel="stylesheet" type="text/css" href="/CSS/Site.less?b8193c8e87d1b1f3cc6b8ad5ef3d9a1ac2b68961" />
<script src="/Scripts/jquery-1.7.1.js?b47730ffaec4272a8a01756af2ef13ecea1c4e92" type="text/javascript"></script>
<script src="/Scripts/app.coffee?57818a7855d3931d2884ff32e0949888a225f0d1" type="text/javascript"></script>
**Note**: To serve .less and .coffee-files individually in debug mode, you need to add their respective HTTP handlers manually (or via NuGet) to your web project.
Available modules
-----------------
To use a module, simply make a project reference, it will be configured automatically.
**`CacheTag.Mvc`**
Registers routes and an MVC controller for serving scripts
**`CacheTag.Modules.AjaxMin`**
Minifies scripts and stylesheets using AjaxMin, depends on `AjaxMin`
**`CacheTag.Modules.DotLess`**
Support for .less style sheets files, depends on `dotless.Core`
**`CacheTag.Modules.SassAndCoffee`**
Provides support for .coffee-scripts for now, depends on `SassAndCoffee.Core` and `SassAndCoffee.JavaScript`
Configuration
-------------
The idea is sane defaults and zero configuration, but there are some things you can configure if you want.
`CacheTag.Core.Configuration.Settings`.**`HashAlgorithm`**
MD5 is used by default
`CacheTag.Core.Configuration.Settings`.**`RuntimeMode`**
Default mode is Dynamic, other options are ForceDebug or ForceRelease
`CacheTag.Mvc.MvcSettings`.**`RouteUrl`**
Default value is `"_cachetag/{id}"`
Create your own module
----------------------
Implement ICacheTagModule and it will automatically be run on startup.
:::csharp
public class ModuleConfiguration : ICacheTagModule
{
public void Initialize()
{
CacheTag.Core.Configuration.Settings.RuntimeMode = RuntimeMode.ForceRelease;
}
}
Extension methods
-----------------
Most of CacheTag is based around a couple of extension methods operating on either `IEnumerable<IScriptResource>` or `IEnumerable<IStyleResource>`, these are explained here.
**`Compile()`**
When operating in debug mode, Compile() does nothing, it just returns the same list it was passed. When in release mode however, it will compile the list of resources using whatever resource compiler is registered for that type of resource. For instance, when using the AjaxMin module, Compile() will minify the list and return a list of one item.
In release mode Compile() also calls Store(), see below.
**`RenderHtml()`**
Renders HTML script tags with items linked as external resources.
**`RenderHtmlInline()`**
Renders HTML script tags with the resource content inlined.
**`RenderMvcHtml()`**
Calls RenderHtml() but wraps the result in a IHtmlString.
**`RenderMvcHtmlInline()`**
Calls RenderHtmlInline() but wraps the result in a IHtmlString.
**`Store()`**
When serving items as external resources they have to be stored somewhere so they can be retrieved when the browser next requests them. Therefore Store() saves the list of resources in a static Dictionary<> in the class ResourceStorage.
When running a site in production, scripts and styles tend to be static, so storing your compiled resources in a static dictionary should not be a problem.
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
Binary file not shown.
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
<NuGetExePath>$(NuGetToolsPath)\nuget.exe</NuGetExePath>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
<PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
<PackageSources>""</PackageSources>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition="$(RestorePackages) == ''">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition="$(BuildPackage) == ''">false</BuildPackage>

<!-- Commands -->
<RestoreCommand>"$(NuGetExePath)" install "$(PackagesConfig)" -source $(PackageSources) -o "$(PackagesDir)"</RestoreCommand>
<BuildCommand>"$(NuGetExePath)" pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="!Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true" />
</Target>
</Project>
@@ -0,0 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(BuildTargetDir)' != ''">
<BaseIntermediateOutputPath>$(BuildTargetDir)\obj\</BaseIntermediateOutputPath>
<OutputPath>$(BuildTargetDir)</OutputPath>
</PropertyGroup>
</Project>
@@ -0,0 +1,28 @@
using System;
using System.Web;
using System.Web.Caching;

namespace CacheTag.Core.Cache
{
public class HttpRuntimeCacheProvider : ICacheProvider
{
public T Get<T>(string key)
where T : class
{
return HttpRuntime.Cache.Get(key) as T;
}

public void Put<T>(string key, T value, CacheDependency cacheDependency, DateTime? absoluteExpiration)
where T : class
{
HttpRuntime.Cache.Add(
key,
value,
cacheDependency,
absoluteExpiration ?? System.Web.Caching.Cache.NoAbsoluteExpiration,
System.Web.Caching.Cache.NoSlidingExpiration,
CacheItemPriority.Normal,
null);
}
}
}
@@ -0,0 +1,12 @@
using System;
using System.Web.Caching;

namespace CacheTag.Core.Cache
{
public interface ICacheProvider
{
T Get<T>(string key) where T : class;

void Put<T>(string key, T value, CacheDependency cacheDependency, DateTime? absoluteExpiration) where T : class;
}
}

0 comments on commit f99097d

Please sign in to comment.
You can’t perform that action at this time.