Beispiel #1
0
        public string Render(string contentTypeAlias, IDictionary <string, object> dataValues, string viewName)
        {
            var content = new PublishedFragment(contentTypeAlias, dataValues, true);

            var routeVals = new RouteData();

            routeVals.Values.Add("controller", "Fragment");
            routeVals.Values.Add("action", "Index");
            routeVals.DataTokens.Add("umbraco-context", _umbracoContext); //required for UmbracoViewPage

            var    request = new RequestContext(_httpContext, routeVals);
            string output;

            using (var controller = new FragmentController(viewName, content))
            {
                controller.ControllerContext = new ControllerContext(request, controller);
                var result = controller.Index();

                using (var sw = new StringWriter())
                {
                    EnsureViewObjectDataOnResult(controller, result);
                    var viewContext2 = new ViewContext(controller.ControllerContext, result.View, result.ViewData, result.TempData, sw);
                    result.View.Render(viewContext2, sw);
                    foreach (var v in result.ViewEngineCollection)
                    {
                        v.ReleaseView(controller.ControllerContext, result.View);
                    }
                    output = sw.ToString().Trim();
                }
            }

            return(output);
        }
        public string Render(string razor, string contentTypeAlias, IDictionary <string, object> dataValues)
        {
            // fixme - what shall we initialize?
            var macro = new MacroModel();

            macro.ScriptName = "NOSCRIPT";
            macro.ScriptCode = @"
@inherits UmbracoViewPage<IPublishedContent>
<div>
    <span>zz</span>
    <span>@Model.GetPropertyValue(""title"")</span>
</div>
";

            // fixme - ispreviewing?
            var publishedContent = new PublishedFragment(contentTypeAlias, dataValues, true);

            // fixme - handle exceptions?!
            var result = LoadPartialViewMacro(macro, publishedContent);

            return(result.Result);
        }
Beispiel #3
0
 public PublishedProperty(PublishedPropertyType propertyType, PublishedFragment content, object dataValue)
     : base(propertyType)
 {
     _dataValue = dataValue;
     _content   = content;
 }
Beispiel #4
0
 public PublishedProperty(PublishedPropertyType propertyType, PublishedFragment content)
     : base(propertyType)
 {
     _dataValue = null;
     _content   = content;
 }