<#+

private void GenerateHeaderFooter()
{
    const string DEFAULT_INDENT = "    ";
    var headerTitle = Options["Header"]["Title"];
    var headerStyle = Options["Header"]["Style"];
    var footerTitle = Options["Footer"]["Title"];
    var footerStyle = Options["Footer"]["Style"];
    var endLine = IsVB ? " _" : "";

    PushIndent(DEFAULT_INDENT);

    // Header
    if(!string.IsNullOrEmpty(headerTitle))
    {
        WriteLine(endLine);
        Write(".Header(\"" + headerTitle + "\")");
    }

    // HeaderStyle
    if(headerStyle["IsDirty"])
    {
        WriteLine(endLine);
        if(IsVB)
        {
            Write(".HeaderStyle(Sub(style) style");
        }
        else
        {
            Write(".HeaderStyle(style => style");
        }
        GenerateStyle(headerStyle);
        Write(")");
    }

    // Footer
    if(!string.IsNullOrEmpty(footerTitle))
    {
        WriteLine(endLine);
        Write(".Footer(\"" + footerTitle + "\")");
    }

    // FooterStyle
    if(footerStyle["IsDirty"])
    {
        WriteLine(endLine);
        if(IsVB)
        {
            Write(".FooterStyle(Sub(style) style");
        }
        else
        {
            Write(".FooterStyle(style => style");
        }
        GenerateStyle(footerStyle);
        Write(")");
    }

    PopIndent();
}

private void GenerateStyle(dynamic style)
{
    if(!string.IsNullOrEmpty(style["Fill"]))
    {
        Write(".Fill(\"" + style["Fill"] + "\")");
    }
    if(!string.IsNullOrEmpty(style["FontFamily"]))
    {
        Write(".FontFamily(\"" + style["FontFamily"] + "\")");
    }
    if(!string.IsNullOrEmpty(style["FontSize"]))
    {
        Write(".FontSize(\"" + style["FontSize"] + "\")");
    }
    if(!string.IsNullOrEmpty(style["Foreground"]))
    {
        Write(".Foreground(\"" + style["Foreground"] + "\")");
    }
    if(style["Halign"] != "center")
    {
        Write(".Halign(\"" + style["Halign"] + "\")");
    }
}

#>