예제 #1
0
        private static void CreateCrushedFiles(IPathProvider pathProvider, CssGroupElementCollection cssGroups, JsGroupElementCollection jsGroups, CssCrusher cssCrusher, JsCrusher jsCrusher)
        {
            _cssOutput = "Css Files created:\r\n";
            foreach (CssGroupElement group in cssGroups)
            {
                var files = new List <CssFile>();

                foreach (CssFileElement cssFile in group.Files)
                {
                    var file = new CssFile()
                    {
                        CompressionType = cssFile.CompressionType,
                        FilePath        = cssFile.FilePath
                    };
                    files.Add(file);
                }

                var outputUri = new Uri(pathProvider.ToAbsolute(group.OutputFilePath), UriKind.Relative);
                cssCrusher.AddFiles(outputUri, files, group.AppendHashToCssAsset);

                _cssOutput += outputUri + " (" + group.Name + ")\r\n";
                foreach (var cssFile in files)
                {
                    outputUri   = new Uri(pathProvider.ToAbsolute(cssFile.FilePath), UriKind.Relative);
                    _cssOutput += "    " + outputUri + "\r\n";
                }
            }

            _jsOutput = "Js Files created:\r\n";
            foreach (JsGroupElement group in jsGroups)
            {
                var files = new List <JsFile>();

                foreach (JsFileElement cssFile in group.Files)
                {
                    var file = new JsFile()
                    {
                        CompressionType = cssFile.CompressionType,
                        FilePath        = cssFile.FilePath
                    };
                    files.Add(file);
                }

                var outputUri = new Uri(pathProvider.ToAbsolute(group.OutputFilePath), UriKind.Relative);
                jsCrusher.AddFiles(outputUri, files);

                _jsOutput += outputUri + " (" + group.Name + ")\r\n";
                foreach (var jsFile in files)
                {
                    outputUri  = new Uri(pathProvider.ToAbsolute(jsFile.FilePath), UriKind.Relative);
                    _jsOutput += "    " + outputUri + "\r\n";
                }
            }
        }
예제 #2
0
 public ISmidgeRequire RequiresCss(CssFile file)
 {
     if (_type == WebFileType.Js)
     {
         throw new InvalidOperationException("Cannot add js file to a css bundle");
     }
     if (_requestHelper.IsExternalRequestPath(file.FilePath))
     {
         throw new InvalidOperationException("Cannot process an external file as part of a bundle");
     }
     _bundleManager.AddToBundle(_bundleName, file);
     return(this);
 }
예제 #3
0
        /// <summary>
        /// Adds an item to the bundle, if the bundle doesn't exist it will be created
        /// </summary>
        /// <param name="bundleName"></param>
        /// <param name="file"></param>
        public void AddToBundle(string bundleName, CssFile file)
        {
            Bundle collection;

            if (TryGetValue(bundleName, out collection))
            {
                collection.Files.Add(file);
            }
            else
            {
                Create(bundleName, file);
            }
        }
예제 #4
0
        private static string GetPath(CssFile cssFile)
        {
            string path;
            switch (cssFile)
            {
                case CssFile.Core: path = "/Open.Core/Css/Core.css"; break;
                case CssFile.CoreControls: path = "/Open.Core/Css/Core.Controls.css"; break;
                case CssFile.CoreLists: path = "/Open.Core/Css/Core.Lists.css"; break;
                case CssFile.JQueryUi: path = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"; break;

                default: throw new NotSupportedException(cssFile.ToString());
            }
            return path.PrependDomain();
        }
예제 #5
0
        /// <summary>
        /// Adds an item to the bundle, if the bundle doesn't exist it will be created
        /// </summary>
        /// <param name="bundleName"></param>
        /// <param name="file"></param>
        public void AddToBundle(string bundleName, CssFile file)
        {
            Bundle collection;

            if (TryGetValue(bundleName, out collection))
            {
                _logger.LogDebug($"Adding {WebFileType.Css} file '{file.FilePath}' to bundle '{bundleName}'");
                collection.Files.Add(file);
            }
            else
            {
                Create(bundleName, file);
            }
        }
예제 #6
0
        public static HtmlHelper RequiresCssFolder(this HtmlHelper html, string folderPath, string searchFilter, int priority, int group, object htmlAttributes, string forcedProvider)
        {
            return(html.RequiresFolder(folderPath, searchFilter, (absPath) =>
            {
                var file = new CssFile(absPath)
                {
                    ForceProvider = forcedProvider,
                    Group = @group,
                    Priority = priority
                };

                //now add the attributes to the list
                foreach (var d in htmlAttributes.ToDictionary())
                {
                    file.HtmlAttributes.Add(d.Key, d.Value.ToString());
                }

                html.RequiresJs(file);
            }));
        }
예제 #7
0
 /// <summary>Gets the embed tag for the specified script.</summary>
 /// <param name="cssFile">Flag indicating what css file to retrieve the path for.</param>
 public string this[CssFile cssFile]
 {
     get { return ToCssLink(GetPath(cssFile)); }
 }
예제 #8
0
        public static CssFileResult GetData(AccountList list, CssAccountFile file, CssCredentials cssCredentials)
        {
            var lHostName    = cssCredentials.Hostname;
            var lAccount     = cssCredentials.Account;
            var lUser        = cssCredentials.User;
            var lPassword    = cssCredentials.UserPassword;
            var lServiceType = cssCredentials.ServiceType;

            var response    = new CssFileResult();
            var fileResults = new CssFile {
                FileName = list.AccountListName
            };

            UniSession us = null;

            try
            {
                //get the session object
                us = UniObjects.OpenSession(lHostName, lUser, lPassword, lAccount, lServiceType);

                // create select list
                UniSelectList selectList = us.CreateUniSelectList(2);
                selectList.GetList(list.AccountListName);

                // read records using array of records ids
                var ids = selectList.ReadListAsStringArray();

                //open file
                UniFile cssFile = us.CreateUniFile(file.FileName);
                var     lSet    = cssFile.ReadRecords(ids);

                //var dict = us.CreateUniDictionary(file.FileName);
                //var field1 = dict.ReadField(1);

                //use foreach statement to construct data to be displayed
                foreach (UniRecord item in lSet)
                {
                    var record    = new CssRecord(item.RecordID, "");
                    var numFields = item.Record.Dcount();
                    for (int i = 0; i < numFields; i++)
                    {
                        var field = item.Record.Extract(i);

                        var valuesCount = field.Dcount();
                        if (valuesCount > 1)
                        {
                            throw new Exception("This field has sub-values" + field);
                        }
                        record.Fields.Add(new CssField(i.ToString(), field.ToString()));
                    }
                    fileResults.Records.Add(record);
                }

                response.FileContents = fileResults;

                return(response);
            }
            catch (Exception ex)
            {
                response.CssResponses.Results.Add(new CommandResponse("Exception", ex.ToString()));
            }
            finally
            {
                if (us != null && us.IsActive)
                {
                    UniObjects.CloseSession(us);
                }
            }
            response.CssResponses.Results.Add(new CommandResponse("Error", "There was an error procesing your request."));
            return(response);
        }
예제 #9
0
 public SmidgeHelper RequiresCss(CssFile file)
 {
     _context.Files.Add(file);
     return(this);
 }
예제 #10
0
 public ISmidgeRequire RequiresCss(CssFile file)
 {
     _dynamicallyRegisteredWebFiles.Files.Add(file);
     return(this);
 }
 public CssFileResult()
 {
     CssResponses = new CssCommandResult();
     FileContents = new CssFile();
 }
 public void Save(CssFile file)
 {
     _fileRepo.SaveString(file.FilePath, file.Content);
 }
예제 #13
0
 public ISmidgeRequire RequiresCss(CssFile file)
 {
     return(this);
 }