コード例 #1
0
        /// <summary>
        /// Builds the view engine collection by applying the passed path transformations to each view engine.
        /// </summary>
        /// <param name="pathTransformations">The path transformations.</param>
        private static ViewEngineCollection BuildViewEngineCollection(IList <Func <string, string> > pathTransformations)
        {
            var viewEngines = new ViewEngineCollection();

            foreach (var globalEngine in ViewEngines.Engines)
            {
                var vppEngine = globalEngine as VirtualPathProviderViewEngine;
                var newEngine = vppEngine != null?ControllerExtensions.GetViewEngine(vppEngine, pathTransformations) : globalEngine;

                if (newEngine != null)
                {
                    viewEngines.Add(newEngine);
                }
            }

            return(viewEngines);
        }
コード例 #2
0
        private static IEnumerable <string> GetViews(Controller controller, IEnumerable <string> viewLocations, string moduleName = null)
        {
            var viewExtensions = ControllerExtensions.GetViewFileExtensions(controller);
            var widgetName     = controller.RouteData != null ? controller.RouteData.Values["widgetName"] as string : null;

            var assembly  = controller.GetType().Assembly;
            var baseFiles = ControllerExtensions.GetViewsForAssembly(assembly, viewLocations, viewExtensions, moduleName);

            if (!widgetName.IsNullOrEmpty())
            {
                var widgetAssembly = FrontendManager.ControllerFactory.ResolveControllerType(widgetName).Assembly;
                var widgetFiles    = ControllerExtensions.GetViewsForAssembly(widgetAssembly, viewLocations, viewExtensions);
                return(baseFiles.Union(widgetFiles));
            }

            return(baseFiles);
        }
コード例 #3
0
        /// <summary>
        /// Gets an already cached view engine collection from the dictionary or builds a new one.
        /// </summary>
        /// <param name="controller">The controller.</param>
        /// <param name="pathTransformationsFunc">The path transformations function.</param>
        private static ViewEngineCollection GetViewEngineCollection(Controller controller, Func <IList <Func <string, string> > > pathTransformationsFunc)
        {
            var key = ControllerExtensions.GetKey(controller);

            if (!ControllerExtensions.ViewEngineCollections.ContainsKey(key))
            {
                lock (ControllerExtensions.ViewEngineCollections)
                {
                    if (!ControllerExtensions.ViewEngineCollections.ContainsKey(key))
                    {
                        var viewEngineCollection = ControllerExtensions.BuildViewEngineCollection(pathTransformationsFunc());
                        ControllerExtensions.ViewEngineCollections.Add(key, viewEngineCollection);
                    }
                }
            }

            return(ControllerExtensions.ViewEngineCollections[key]);
        }
コード例 #4
0
        /// <summary>
        /// Updates the view engines collection of the given <paramref name="controller"/> by making the engines aware of the controller's container virtual path.
        /// </summary>
        /// <param name="controller">The controller.</param>
        /// <exception cref="System.ArgumentNullException">controller</exception>
        /// <param name="pathTransformations">Transformations that have to be applied to each view engine search path.</param>
        public static void UpdateViewEnginesCollection(this Controller controller, IList <Func <string, string> > pathTransformations)
        {
            if (controller == null)
            {
                throw new ArgumentNullException("controller");
            }

            var viewEngines = new ViewEngineCollection();

            foreach (var globalEngine in ViewEngines.Engines)
            {
                var vppEngine = globalEngine as VirtualPathProviderViewEngine;
                var newEngine = vppEngine != null?ControllerExtensions.GetViewEngine(vppEngine, controller, pathTransformations) : globalEngine;

                viewEngines.Add(newEngine);
            }
            controller.ViewEngineCollection = viewEngines;
        }
コード例 #5
0
 /// <summary>
 /// Gets the view paths of the given controller.
 /// </summary>
 /// <param name="controller">The controller.</param>
 private static IEnumerable <string> GetViewLocations(Controller controller)
 {
     return(ControllerExtensions.GetControllerViewEngineLocations(controller, v => v.ViewLocationFormats));
 }
コード例 #6
0
        internal static IEnumerable <string> GetPartialViews(this Controller controller, ref Dictionary <string, string> viewFilesMappings, string moduleName)
        {
            var viewLocations = ControllerExtensions.GetPartialViewLocations(controller);

            return(ControllerExtensions.GetViews(controller, viewLocations, ref viewFilesMappings, moduleName));
        }
コード例 #7
0
 /// <summary>
 /// Gets the type of the dynamic content that is inferred for the given controller name.
 /// </summary>
 /// <param name="controllerName">Name of the controller.</param>
 /// <param name="moduleName">The name of the module. If empty or null will search all dynamic modules. Default value is null.</param>
 /// <returns>
 /// The dynamic module type.
 /// </returns>
 public static DynamicModuleType GetDynamicContentType(string controllerName, string moduleName)
 {
     return(ControllerExtensions.FindDynamicContentTypes(controllerName, moduleName).FirstOrDefault());
 }
コード例 #8
0
 /// <summary>
 /// Gets the type of the dynamic content that is inferred for the given controller name.
 /// </summary>
 /// <param name="controllerName">Name of the controller.</param>
 /// <returns>
 /// The dynamic module type.
 /// </returns>
 public static DynamicModuleType GetDynamicContentType(string controllerName)
 {
     return(ControllerExtensions.GetDynamicContentType(controllerName, null));
 }
コード例 #9
0
 /// <summary>
 /// Gets the partial view paths of the given controller.
 /// </summary>
 /// <param name="controller">The controller.</param>
 public static IEnumerable <string> GetPartialViewLocations(this Controller controller)
 {
     return(ControllerExtensions.GetControllerViewEngineLocations(controller, v => v.PartialViewLocationFormats));
 }
コード例 #10
0
        public static IEnumerable <string> GetViews(this Controller controller, IList <string> fullViewPaths, string moduleName)
        {
            var viewLocations = ControllerExtensions.GetViewLocations(controller);

            return(ControllerExtensions.GetViews(controller, viewLocations, moduleName));
        }
コード例 #11
0
 public static IEnumerable <string> GetViews(this Controller controller, IList <string> fullViewPaths = null)
 {
     return(ControllerExtensions.GetViews(controller, fullViewPaths, null));
 }
コード例 #12
0
        public static IEnumerable <string> GetPartialViews(this Controller controller, IList <string> fullViewPaths = null)
        {
            var viewLocations = ControllerExtensions.GetPartialViewLocations(controller);

            return(ControllerExtensions.GetViews(controller, viewLocations));
        }
コード例 #13
0
        /// <summary>
        /// Gets the views that are available to the controller.
        /// </summary>
        /// <param name="controller">The controller.</param>
        public static IEnumerable <string> GetViews(this Controller controller)
        {
            var viewLocations = ControllerExtensions.GetViewLocations(controller);

            return(ControllerExtensions.GetViews(controller, viewLocations));
        }
コード例 #14
0
        internal static IEnumerable <string> GetPartialViews(this Controller controller, ref Dictionary <string, string> viewFilesMappings, IList <string> fullViewPaths = null)
        {
            var viewLocations = ControllerExtensions.GetPartialViewLocations(controller);

            return(ControllerExtensions.GetViews(controller, viewLocations, ref viewFilesMappings));
        }