예제 #1
0
        public static CachedViewKey Get(string viewPath, string languageCultureCode, string area)
        {
            //for creating cached view key, we need url of the page,
            //we first get controller and action from view path and try to find the url for it.
            var url     = viewPath;
            var context = "";

            if (viewPath.Contains("/"))
            {
                var viewPathParts = viewPath.Split("/", StringSplitOptions.RemoveEmptyEntries);
                if (viewPathParts.Length > 1)
                {
                    var controller = viewPathParts[0];
                    var action     = viewPathParts[1];
                    var route      = RouteFinder.GetAllRoutes(controller, area)
                                     .FirstOrDefault(x => x.Action.Equals(action, StringComparison.InvariantCultureIgnoreCase));
                    if (route != null)
                    {
                        url = "/" + route.Template;
                    }
                    context = controller;
                }
            }
            return(new CachedViewKey()
            {
                Url = url.ToLower(),
                LanguageCultureCode = languageCultureCode,
                ViewPath = viewPath,
                Context = context,
                Area = area
            });
        }
예제 #2
0
        public Dictionary <string, object> CompileAllViews(string controller = null, string area = null, bool splitted = false)
        {
            //get all the routes
            var routes = RouteFinder.GetAllRoutes(controller, area);
            //conventionally we use the same name for views as our action name
            const string pathFormat = "{0}/{1}";

            foreach (var route in routes)
            {
                var viewPath      = string.Format(pathFormat, route.Controller, route.Action);
                var themeViewPath = GetThemeViewPath(viewPath);
                if (themeViewPath.IsNullEmptyOrWhiteSpace())
                {
                    continue;
                }
                GetView(themeViewPath, viewPath, area);
            }
            return(GetCompiledViews(splitted, area));
        }