public string ExecuteWithLayout(ICompiledRazorTemplate innerTemplate, RazorEngineExecutionSettings executionSettings) { Contract.Requires(innerTemplate != null); Contract.Requires(executionSettings != null); Contract.Ensures(Contract.Result <string>() != null); throw new System.NotImplementedException(); }
private static void SetTemplateProperties( RazorEngineExecutionSettings executionSettings, object template) { foreach (KeyValuePair <string, object> propertyPair in executionSettings.Properties) { try { Type compiledTemplateType = template.GetType(); PropertyInfo property = compiledTemplateType.GetProperty(propertyPair.Key); if (property != null) { property.SetValue(template, propertyPair.Value, null); } else { //throw new InvalidOperationException("Property {0} does not exist".Fmt(propertyPair.Key)); } } catch (Exception ex) { log.ErrorFormat( "Cannot set template property '{0}' to '{1}: {2}", propertyPair.Key, propertyPair.Value, ex); throw; } } }
public string Execute(RazorEngineExecutionSettings executionSettings) { if (LayoutTemplate != null) { return(LayoutTemplate.ExecuteWithLayout(this, executionSettings)); } object template = CreateTemplateInstance(); SetTemplateProperties(executionSettings, template); ExecuteMethod(template); return(FetchTemplateOutput(template)); }
public string ExecuteWithLayout(ICompiledRazorTemplate innerTemplate, RazorEngineExecutionSettings executionSettings) { if (LayoutTemplate != null) { throw new InvalidOperationException("Cannot execute this method on an inner template"); } object innerTemplateInstance = innerTemplate.CreateTemplateInstance(); SetTemplateProperties(executionSettings, innerTemplateInstance); ExecuteMethod(innerTemplateInstance); string innerBody = FetchTemplateOutput(innerTemplateInstance); object layoutTemplateInstance = CreateTemplateInstance(); SetLayoutInnerTemplate(layoutTemplateInstance, innerTemplateInstance, innerBody); ExecuteMethod(layoutTemplateInstance); return(FetchTemplateOutput(layoutTemplateInstance)); }
public string Execute(RazorEngineExecutionSettings executionSettings) { Contract.Requires(executionSettings != null); Contract.Ensures(Contract.Result <string>() != null); throw new System.NotImplementedException(); }