-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
I've developed a MvcTemplateBase and MvcTemplateBase and I need to set some properties on those types before execute, like one called ViewData. So I would need to execute the following sequence:
Type modelType = model.GetType();
ITemplate template = machine.Context.TemplateFactory.CreateTemplateInstance(viewName, modelType);
MvcTemplateBase mvcTemplate = (MvcTemplateBase)machine.Context.TemplateFactory.CreateTemplateInstance(viewName);
ITemplateInternal templateInternal = (ITemplateInternal)template;
templateInternal.SetModel(model);
mvcTemplate.ModelTypeForMetadata = new TypeWrapper(metadataModelDefinition, modelType);
if (viewData == null)
{
viewData = new System.Web.Mvc.ViewDataDictionary();
}
viewData.Model = model;
mvcTemplate.SetViewData(viewData);
mvcTemplate.TempFolder = tempFolder; // custom stuff
mvcTemplate.Execute();
templateInternal.Execute();
machine.ExecuteUrl(viewName, model);
if (layoutName != null)
mvcTemplate.Layout = layoutName;
templateInternal.TryApplyLayout();
One problem I had, is that ITemplateInternal is internal, and I had to make it public to be able to call ITemplateInternal methods.
Let me know if I'm not clear enough or if I can contribute with this.
Metadata
Metadata
Assignees
Labels
No labels