Exemple #1
0
        internal static Skin GetLayout(string layoutName)
        {
            if (layoutName == string.Empty)
            {
                return(null);
            }

            string skinFileName = string.Empty;

            IHttpServerUtility s = WebAppContext.Server;

            if (layoutName == null)
            {
                skinFileName = string.Format("{0}/Layouts/{1}.html", WebAppConfig.ThemePath, WebAppConfig.DefaultLayout);
            }
            else
            {
                skinFileName = string.Format("{0}/Layouts/{1}.html", WebAppConfig.ThemePath, layoutName);
            }

            string skinFile = s.MapPath(skinFileName);

            if (File.Exists(skinFile))
            {
                return(Skin.CreateInstance(skinFile));
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
 public ThemeService(
     ICultureInfo cultureInfo,
     IFileSystem fileSystem,
     IHttpServerUtility httpServerUtility,
     IProfileLogger profileLogger)
 {
     _cultureInfo       = cultureInfo;
     _fileSystem        = fileSystem;
     _httpServerUtility = httpServerUtility;
     _profileLogger     = profileLogger;
 }
Exemple #3
0
        internal static Skin GetSkin(string viewName, string actionMethod)
        {
            if (string.IsNullOrEmpty(viewName))
            {
                throw new ArgumentException("viewName");
            }

            if (string.IsNullOrEmpty(actionMethod))
            {
                throw new ArgumentException("actionMethod");
            }

            string skinFile;
            string key = viewName + "|" + actionMethod;

            if (!_cache.TryGetValue(key, out skinFile))
            {
                string skinFileName;

                int pos = viewName.LastIndexOf('/');

                if (pos == -1)
                {
                    skinFileName = string.Format("{0}/Skins/_{1}/{2}.html", WebAppConfig.ThemePath, viewName, actionMethod);
                }
                else
                {
                    skinFileName = string.Format("{0}/Skins/{1}/_{2}/{3}.html", WebAppConfig.ThemePath, viewName.Substring(0, pos), viewName.Substring(pos + 1), actionMethod);
                }

                IHttpServerUtility s = WebAppContext.Server;

                if (!File.Exists(s.MapPath(skinFileName)))
                {
                    skinFileName = string.Format("{0}/Skins/{1}.html", WebAppConfig.ThemePath, viewName);

                    if (!File.Exists(s.MapPath(skinFileName)))
                    {
                        throw new FileNotFoundException("Unable to find the skin file.", skinFileName);
                    }
                }

                skinFile = s.MapPath(skinFileName);
                _cache.Add(key, skinFile);
            }

            return(Skin.CreateInstance(skinFile));
        }