Example #1
0
 public SparkViewDescriptor CreateDescriptor(ActionContext actionContext, string viewName, string masterName, bool findDefaultMaster, ICollection <string> searchedLocations)
 {
     return(DescriptorBuilder.BuildDescriptor(
                new BuildDescriptorParams(
                    actionContext.ActionNamespace,
                    actionContext.ActionName,
                    viewName,
                    masterName,
                    findDefaultMaster,
                    DescriptorBuilder.GetExtraParameters(actionContext)),
                searchedLocations));
 }
        public SparkViewDescriptor CreateDescriptor(
            ControllerContext controllerContext,
            string viewName,
            string masterName,
            bool findDefaultMaster,
            ICollection <string> searchedLocations)
        {
            var targetNamespace = controllerContext.Controller.GetType().Namespace;

            var controllerName = controllerContext.RouteData.GetRequiredString("controller");

            return(DescriptorBuilder.BuildDescriptor(
                       new BuildDescriptorParams(
                           targetNamespace,
                           controllerName,
                           viewName,
                           masterName,
                           findDefaultMaster,
                           DescriptorBuilder.GetExtraParameters(controllerContext)),
                       searchedLocations));
        }
        private ViewEngineResult FindViewInternal(ControllerContext controllerContext, string viewName, string masterName, bool findDefaultMaster, bool useCache)
        {
            var searchedLocations = new List <string>();
            var targetNamespace   = controllerContext.Controller.GetType().Namespace;

            var controllerName = controllerContext.RouteData.GetRequiredString("controller");

            var descriptorParams = new BuildDescriptorParams(
                targetNamespace,
                controllerName,
                viewName,
                masterName,
                findDefaultMaster,
                DescriptorBuilder.GetExtraParameters(controllerContext));

            ISparkViewEntry entry;

            if (useCache)
            {
                if (TryGetCacheValue(descriptorParams, out entry) && entry.IsCurrent())
                {
                    return(BuildResult(controllerContext.RequestContext, entry));
                }
                return(_cacheMissResult);
            }

            var descriptor = DescriptorBuilder.BuildDescriptor(
                descriptorParams,
                searchedLocations);

            if (descriptor == null)
            {
                return(new ViewEngineResult(searchedLocations));
            }

            entry = Engine.CreateEntry(descriptor);
            SetCacheValue(descriptorParams, entry);
            return(BuildResult(controllerContext.RequestContext, entry));
        }
Example #4
0
        private ViewEngineResult findViewInternal(ActionContext actionContext, string viewName, string masterName, bool findDefaultMaster, bool useCache)
        {
            var searchedLocations = new List <string>();
            var targetNamespace   = actionContext.ActionNamespace;

            var descriptorParams = new BuildDescriptorParams(
                targetNamespace,
                actionContext.ActionName,
                viewName,
                masterName,
                findDefaultMaster,
                DescriptorBuilder.GetExtraParameters(actionContext));

            ISparkViewEntry entry;

            if (useCache)
            {
                if (tryGetCacheValue(descriptorParams, out entry) && entry.IsCurrent())
                {
                    return(buildResult(entry));
                }

                return(new ViewEngineResult(new List <string> {
                    "Cache"
                }));
            }

            var descriptor = DescriptorBuilder.BuildDescriptor(descriptorParams, searchedLocations);

            if (descriptor == null)
            {
                return(new ViewEngineResult(searchedLocations));
            }

            entry = Engine.CreateEntry(descriptor);
            setCacheValue(descriptorParams, entry);

            return(buildResult(entry));
        }
Example #5
0
        private ViewEngineResult FindViewInternal(ActionContext actionContext, string viewName, string masterName, bool findDefaultMaster, bool useCache)
        {
            var searchedLocations = new List <string>();
            var viewPath          = actionContext.ViewPath;

            var descriptorParams = new BuildDescriptorParams(
                viewPath,
                viewName,
                masterName,
                findDefaultMaster,
                DescriptorBuilder.GetExtraParameters(actionContext));

            ISparkViewEntry entry;

            if (useCache)
            {
                if (TryGetCacheValue(descriptorParams, out entry) && entry.IsCurrent())
                {
                    return(BuildResult(actionContext.HttpContext, entry));
                }

                return(cacheMissResult);
            }

            var descriptor = DescriptorBuilder.BuildDescriptor(
                descriptorParams,
                searchedLocations);

            if (descriptor == null)
            {
                return(new ViewEngineResult(searchedLocations));
            }

            entry = Engine.CreateEntry(descriptor);
            this.SetCacheValue(descriptorParams, entry);
            return(BuildResult(actionContext.HttpContext, entry));
        }