/// <summary>
 /// Serializes any IAlert stack, using the derived classes Append Methods
 /// </summary>
 /// <param name="n"></param>
 /// <returns></returns>
 /// <remarks></remarks>
 public virtual string Serialize(IFluentAlert n, Func<string, string> modifyResults = null)
 {
     var sb = new StringBuilder();  //new string builder used so nothing will carry forward for each message
     ConvertAndAppend(n, sb);
     var results = sb.ToString();
     return (modifyResults == null)
         ? results
         : modifyResults(results);
 }
 /// <summary>
 /// Turns IAlert into most derived type so that serialization can occur at the most detailed level
 /// </summary>
 /// <param name="n"></param>
 /// <param name="sb"></param>
 /// <remarks></remarks>
 private void ConvertAndAppend(IFluentAlert n, StringBuilder sb)
 {
     if (n == null) return;
     if (n is CompositeFluentAlert)
     {
         AppendSerialization((CompositeFluentAlert)n, sb);
     }
     else if (n is FluentAlertTable)
     {
         AppendSerialization((FluentAlertTable)n, sb);
     }
     else if (n is FluentAlertSeperator)
     {
         AppendSerialization((FluentAlertSeperator)n, sb);
     }
     else if (n is FluentAlertTextBlock)
     {
         AppendSerialization((FluentAlertTextBlock)n, sb);
     }
     else if (n is FluentAlertUrl)
     {
         AppendSerialization((FluentAlertUrl)n, sb);
     }
 }
 public void GivenAnAlert()
 {
     if(_builder == null) GivenANonEmptyBuilder();
     _alert = _builder.ToAlert();
 }
 public FluentAlertException(IFluentAlert alert, Exception inner)
     : base(alert.ToText(s => s.Replace(Environment.NewLine, string.Empty)), inner)
 {
     Alert = alert;
 }