Beispiel #1
0
        public override void Process(string templateName, string layoutName, TextWriter output,
                                     IDictionary <string, object> parameters)
        {
            IEngineContext engineContext = null;

            if (HttpContext.Current != null)
            {
                engineContext = (IEngineContext)HttpContext.Current.Items["currentmrengineinstance"];
            }

            var controllerContext = new BasicControllerContext
            {
                SelectedViewName = templateName
            };

            if (!string.IsNullOrEmpty(layoutName))
            {
                controllerContext.LayoutNames = new[] { layoutName }
            }
            ;

            if (parameters != null)
            {
                foreach (var parameter in parameters)
                {
                    controllerContext.PropertyBag[parameter.Key] = parameter.Value;
                }
            }

            if (engineContext != null)
            {
                var controller = engineContext.CurrentController as Controller;
                if (controller != null)
                {
                    foreach (string key in controller.Helpers.Keys)
                    {
                        controllerContext.Helpers.Add(key, controller.Helpers[key]);
                    }
                }
            }

            Process(templateName, output, engineContext, null, controllerContext);
        }
Beispiel #2
0
        public override void Process(string templateName, string layoutName, TextWriter output,
            IDictionary<string, object> parameters)
        {
            IEngineContext engineContext = null;
            if (HttpContext.Current != null)
            {
                engineContext = (IEngineContext)HttpContext.Current.Items["currentmrengineinstance"];
            }

            var controllerContext = new BasicControllerContext
                                        {
                                            SelectedViewName = templateName
                                        };

            if (!string.IsNullOrEmpty(layoutName))
                controllerContext.LayoutNames = new[] { layoutName };

            if (parameters != null)
            {
                foreach (var parameter in parameters)
                    controllerContext.PropertyBag[parameter.Key] = parameter.Value;
            }

            if (engineContext != null)
            {
                var controller = engineContext.CurrentController as Controller;
                if (controller != null)
                {
                    foreach (string key in controller.Helpers.Keys)
                        controllerContext.Helpers.Add(key, controller.Helpers[key]);
                }
            }

            Process(templateName, output, engineContext, null, controllerContext);
        }