Exemplo n.º 1
0
        /// <summary>
        /// Renders the specified settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <param name="writer">The writer.</param>
        private void RenderRelease(XmlSettings settings, HtmlTextWriter writer)
        {
            foreach (var filegroup in settings.FileGroups)
            {
                var action = filegroup.GetCompressorAction();
                var path = this.PhysicalFolder + filegroup.MinifiedFileName;
                string version = string.Empty;
                if (File.Exists(path))
                {
                    version = "?v=" + File.GetLastWriteTimeUtc(path).ToIsoDateFormat(ignoretime: false);
                }

                if (action == CompressorAction.CssCompression)
                {
                    var tag = VTag.Link.AddAttribute("ref", "stylesheet").AddAttribute("type", "text/css");
                    tag.AddAttribute("href", string.Concat(this.PhysicalFolder, filegroup.MinifiedFileName, version));
                    writer.WriteLine(tag);
                }
                else
                {
                    var tag = VTag.Script.AddAttribute("type", "text/javascript");
                    tag.AddAttribute("src", string.Concat(this.PhysicalFolder, filegroup.MinifiedFileName, version));
                    writer.WriteLine(tag);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompressManager"/> class.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="currentdirectory">The currentdirectory.</param>
 public CompressManager(XmlSettings settings, string currentdirectory)
     : this()
 {
     this.XmlSettings = settings;
     this.CurrentDirectory = currentdirectory.EnsureEndsWith(@"\");
 }
Exemplo n.º 3
0
 /* ReSharper disable UnusedMember.Local */
 /// <summary>
 /// Renders the debug.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="writer">The writer.</param>
 /// <example>
 /// The example config:
 /// <code lang="xml">
 /// <![CDATA[
 /// <?xml version="1.0" encoding="utf-16"?>
 /// <yuicompressor debug="false">
 ///  <filegroups>
 ///    <filegroup minfilename="VForms.min.js">
 ///      <files>
 ///        <file>VForms.js</file>
 ///        <file>VForms.vc.js</file>
 ///      </files>
 ///    </filegroup>
 ///    <filegroup minfilename="Test-VForms.min.js">
 ///      <files>
 ///        <file>VForms.js</file>
 ///        <file>VForms.vc.js</file>
 ///      </files>
 ///    </filegroup>
 ///  </filegroups>
 /// </yuicompressor>
 /// ]]>
 /// </code>
 /// </example>
 private void RenderDebug(XmlSettings settings, HtmlTextWriter writer)
 {
     var tick = DateTime.UtcNow.ToIsoDateFormat(ignoretime: false);
     foreach (var filegroup in settings.FileGroups)
     {
         var action = filegroup.GetCompressorAction();
         if (action == CompressorAction.CssCompression)
         {
             foreach (var file in filegroup.Files)
             {
                 var tag = VTag.Link.AddAttribute("ref", "stylesheet").AddAttribute("type", "text/css");
                 tag.AddAttribute("href", string.Concat(this.PhysicalFolder, file, "?v=", tick));
                 writer.WriteLine(tag);
             }
         }
         else
         {
             foreach (var file in filegroup.Files)
             {
                 var tag = VTag.Script.AddAttribute("type", "text/javascript");
                 tag.AddAttribute("src", string.Concat(this.PhysicalFolder, file, "?v=", tick));
                 writer.WriteLine(tag);
             }
         }
     }
 }