Beispiel #1
0
 public void UseFileIfExists(string name)
 {
     if (_folders.FileExists(ContentType.scripts, name))
     {
         Require(name);
     }
 }
Beispiel #2
0
        public ContentFiles(IContentFolderService service, ContentType contentType)
        {
            _service     = service;
            _contentType = contentType;


            /*
             * You might be wondering, "why is it doing this?"
             * The goal of the below is to say:
             * 1.) Use the url to the main application's content/{type} if the file exists there
             * 2.) If not, try to find it in a package folder.  If found, pull it from the package folder
             * 3.) Finally, try the url to the main application and just hope.
             *
             * This implementation isn't smart enough to deal with "appended" virtual directory paths
             *
             */
            _urls.OnMissing = filename =>
            {
                if (_service.ExistsInApplicationDirectory(_contentType, filename))
                {
                    return("~/content/{0}/{1}".ToFormat(_contentType, filename.TrimStart('/')));
                }

                if (_service.FileExists(_contentType, filename))
                {
                    return("~/_content/{0}/{1}".ToFormat(_contentType, filename.TrimStart('/')));
                }

                return("~/content/{0}/{1}".ToFormat(_contentType, filename.TrimStart('/')));
            };
        }
        public ContentFiles(IContentFolderService service, ContentType contentType)
        {
            _service = service;
            _contentType = contentType;

            /*
             * You might be wondering, "why is it doing this?"
             * The goal of the below is to say:
             * 1.) Use the url to the main application's content/{type} if the file exists there
             * 2.) If not, try to find it in a package folder.  If found, pull it from the package folder
             * 3.) Finally, try the url to the main application and just hope.
             *
             * This implementation isn't smart enough to deal with "appended" virtual directory paths
             *
             */
            _urls.OnMissing = filename =>
            {
                if (_service.ExistsInApplicationDirectory(_contentType, filename))
                {
                    return "~/content/{0}/{1}".ToFormat(_contentType, filename.TrimStart('/'));
                }

                if (_service.FileExists(_contentType, filename))
                {
                    return "~/_{0}/{1}".ToFormat(_contentType, filename.TrimStart('/'));
                }

                return "~/content/{0}/{1}".ToFormat(_contentType, filename.TrimStart('/'));
            };
        }