/// <summary>
        /// Adds a CSS file reference to the page's head section.
        /// </summary>
        /// <param name="pathToCSSFileUnderAppPath"></param>
        public void AddCSSFile(CSSGroup cssGroup, string pathToCSSFileUnderAppPath, AggregateMode aggregationMode)
        {
            // -- add only unique items
            string cssPath = pathToCSSFileUnderAppPath.Trim();

            if (!isExternallyHosted(cssPath))
            {
                cssPath = removeBeginningSlash(cssPath);
            }

            CSSGroup?existingGroup = getGroupForCSSFile(cssPath, aggregationMode);

            if (existingGroup == null)
            {
                if (aggregationMode == AggregateMode.Aggregate)
                {
                    cssFilePaths_Aggregate[cssGroup].Add(cssPath);
                }
                else
                {
                    cssFilePaths_DoNotAggregate[cssGroup].Add(cssPath);
                }
            }
            else if (existingGroup != null && existingGroup != cssGroup)
            {
                throw new ArgumentException(cssPath + " has already been added to the " + existingGroup.ToString() + " CSS group");
            }
        } // Add AddCSSFile
        /// Combines locally hosted CSS files into a single file.
        /// Returns the URL of the file that was generated, or string.Empty on error
        private string combineInternalCssFiles(CSSGroup cssGroup, List <string> cssFilePaths, List <EmbeddedCSSFileInfo> embeddedCssFiles)
        {
            if (cssFilePaths.Count == 0 && embeddedCssFiles.Count == 0)
            {
                return("");
            }

            StringBuilder outFileContents = new StringBuilder();

            // -- read each internal file
            foreach (string cssPath in cssFilePaths)
            {
                if (!isExternallyHosted(cssPath))
                {
                    string cssFn = System.Web.Hosting.HostingEnvironment.MapPath("~/" + cssPath);
                    string css   = System.IO.File.ReadAllText(cssFn);
                    outFileContents.Append(css);
                    outFileContents.Append(Environment.NewLine);
                }
            }

            foreach (EmbeddedCSSFileInfo embeddedCss in embeddedCssFiles)
            {
                string[] embeddedNames = embeddedCss.assemblyWithEmbeddedFile.GetManifestResourceNames();
                foreach (string embeddedName in embeddedNames)
                {
                    if (embeddedName.EndsWith(embeddedCss.embeddedFilename, StringComparison.CurrentCultureIgnoreCase))
                    {
                        System.IO.Stream stream = embeddedCss.assemblyWithEmbeddedFile.GetManifestResourceStream(embeddedName);
                        string           css    = new System.IO.StreamReader(stream).ReadToEnd();

                        outFileContents.Append(css);
                        outFileContents.Append(Environment.NewLine);
                        break;
                    }
                }
            } // foreach



            // -- the filename is based on the contents of the file
            string outName = cssGroup.ToString() + "_" + outFileContents.ToString().GetHashCode().ToString();

            outName = System.IO.Path.ChangeExtension(outName, ".css");
            string outUrl = VirtualPathUtility.ToAbsolute("~/_system/writable/css/" + outName);

            string outFn = System.Web.Hosting.HostingEnvironment.MapPath(outUrl);

            if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(outFn)))
            {
                throw new System.IO.FileNotFoundException("Please ensure that the directory exists: ~/system/writable/css/");
            }
            if (!System.IO.File.Exists(outFn))
            {
                System.IO.File.WriteAllText(outFn, outFileContents.ToString(), System.Text.Encoding.UTF8);
            }

            return(outUrl);
        }
 public EmbeddedCSSFileInfo(CSSGroup group, System.Reflection.Assembly assembly, string filename)
 {
     cssGroup = group;
     assemblyWithEmbeddedFile = assembly;
     embeddedFilename         = filename;
 }
        } // Add AddCSSFile

        public void AddEmbeddedCSSFile(CSSGroup cssGroup, System.Reflection.Assembly assemblyWithEmbeddedFile, string embeddedFilename)
        {
            cssEmbeddedResources[cssGroup].Add(new EmbeddedCSSFileInfo(cssGroup, assemblyWithEmbeddedFile, embeddedFilename));
        }
 /// <summary>
 /// Adds a CSS file reference to the page's head section.
 /// </summary>
 /// <param name="pathToCSSFileUnderAppPath"></param>
 public void AddCSSFile(CSSGroup cssGroup, string pathToCSSFileUnderAppPath)
 {
     AddCSSFile(cssGroup, pathToCSSFileUnderAppPath, AggregateMode.Aggregate);
 }