void Render(ExceptionPageTemplateValues values, ExceptionPageTemplateType pageType, Action <string> writer) { if (fragments == null || fragments.Count == 0 || values.Count == 0) { return; } InitFragments(values); string value; foreach (ExceptionPageTemplateFragment fragment in fragments) { if (fragment == null || (fragment.ValidForPageType & pageType) == 0) { continue; } value = values.Get(fragment.Name); if (value == null || !fragment.Visible(values)) { continue; } writer(fragment.ReplaceMacros(value, values)); } }
public string ReplaceMacros(string value, ExceptionPageTemplateValues values) { if (String.IsNullOrEmpty(value)) { return(value); } if (values == null) { throw new ArgumentNullException("values"); } List <string> macroNames = MacroNames; if (macroNames == null || macroNames.Count == 0) { return(value); } var sb = new StringBuilder(value); string macroValue; foreach (string macro in macroNames) { if (String.IsNullOrEmpty(macro)) { continue; } macroValue = values.Get(macro); if (macroValue == null) { macroValue = String.Empty; } sb.Replace("@" + macro + "@", macroValue); } return(sb.ToString()); }
public virtual bool Visible(ExceptionPageTemplateValues values) { List <string> required = RequiredMacros; if (required == null || required.Count == 0) { return(true); } if (values == null || values.Count == 0) { return(false); } foreach (string macro in required) { if (values.Get(macro) == null) { return(false); } } return(true); }
public string ReplaceMacros (string value, ExceptionPageTemplateValues values) { if (String.IsNullOrEmpty (value)) return value; if (values == null) throw new ArgumentNullException ("values"); List <string> macroNames = MacroNames; if (macroNames == null || macroNames.Count == 0) return value; var sb = new StringBuilder (value); string macroValue; foreach (string macro in macroNames) { if (String.IsNullOrEmpty (macro)) continue; macroValue = values.Get (macro); if (macroValue == null) macroValue = String.Empty; sb.Replace ("@" + macro + "@", macroValue); } return sb.ToString (); }
public virtual bool Visible (ExceptionPageTemplateValues values) { List <string> required = RequiredMacros; if (required == null || required.Count == 0) return true; if (values == null || values.Count == 0) return false; foreach (string macro in required) { if (values.Get (macro) == null) return false; } return true; }
void Render (ExceptionPageTemplateValues values, ExceptionPageTemplateType pageType, Action <string> writer) { if (fragments == null || fragments.Count == 0 || values.Count == 0) return; InitFragments (values); string value; foreach (ExceptionPageTemplateFragment fragment in fragments) { if (fragment == null || (fragment.ValidForPageType & pageType) == 0) continue; value = values.Get (fragment.Name); if (value == null || !fragment.Visible (values)) continue; writer (fragment.ReplaceMacros (value, values)); } }