/// <summary> /// Returns <see cref="IOptionObject2015"/> as an HTML string with or without HTML headers. /// </summary> /// <param name="optionObject"></param> /// <param name="includeHtmlHeaders"></param> /// <returns></returns> public static string TransformToHtmlString(IOptionObject2015 optionObject, bool includeHtmlHeaders) { if (optionObject == null) { throw new ArgumentNullException(nameof(optionObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture)); } StringBuilder sb = new StringBuilder(); sb.Append(GetHeader(optionObject.GetType().ToString(), includeHtmlHeaders)); sb.Append(GetHtmlForObject(optionObject, HtmlOutputType.Table)); sb.Append(AddFormTables(optionObject, 2)); sb.Append(GetFooter(includeHtmlHeaders)); return(sb.ToString()); }
/// <summary> /// Returns <see cref="IOptionObject2015"/> as an HTML string with or without HTML headers. /// </summary> /// <param name="optionObject"></param> /// <param name="includeHtmlHeaders"></param> /// <returns></returns> public static string TransformToHtmlString(IOptionObject2015 optionObject, bool includeHtmlHeaders) { if (optionObject == null) { throw new ArgumentNullException("Parameter cannot be null.", "optionObject"); } string html = ""; html += includeHtmlHeaders ? GetHtmlHeader() : ""; html += GetPageHeader(optionObject.GetType().ToString()); html += "<h2>Forms</h2>"; foreach (FormObject formObject in optionObject.Forms) { html += "<h3>Form<h3>"; html += GetHtmlForObject(formObject, HtmlOutputType.Table); html += "<h4>CurrentRow</h4>"; html += GetHtmlForObject(formObject.CurrentRow, HtmlOutputType.Table); html += "<h5>Fields</h5>"; html += "<table>"; html += GetHtmlForObject(formObject.CurrentRow.Fields.FirstOrDefault(), HtmlOutputType.TableHeaders); foreach (FieldObject fieldObject in formObject.CurrentRow.Fields) { html += GetHtmlForObject(fieldObject, HtmlOutputType.TableRow); } html += "</table>"; html += "<h4>OtherRows</h4>"; foreach (RowObject rowObject in formObject.OtherRows) { html += "<h5>Row</h5>"; html += GetHtmlForObject(rowObject, HtmlOutputType.Table); html += "<h6>Fields</h6>"; html += "<table>"; html += GetHtmlForObject(formObject.CurrentRow.Fields.First(), HtmlOutputType.TableHeaders); foreach (FieldObject fieldObject in formObject.CurrentRow.Fields) { html += GetHtmlForObject(fieldObject, HtmlOutputType.TableRow); } html += "</table>"; } } html += includeHtmlHeaders ? GetHtmlFooter() : ""; return(html); }