I am refactoring an existing application that creates a PDF with multiple pages. There are three possible "packages" consisting of one or more PDF templates based upon the number of lines: "One Page," "Two Page," and "Multi Page" (three or more pages).
The routine that is called needs several pieces of information including both String and integer values. I initially used:
Dictionary<int, string[]>
and cast all the ints (other than the first) to string as part of the Dictionary Value and used the Dictionary Key as the Page Number.
In reading several posts on here, it occurred to me that I could use a class and a List<> of classes to store the parameters for each page. This would allow a couple advantages. First, it would allow me to keep the correct datatype for each parameter and it would allow me to use named values.
For Example:
public Class PDFPage
{
public int PageNumber {get; set; }
public string TemplateName {get; set; }
public int TotalPages {get; set; }
...
}
private void CreatePDF()
{
List<PDFPage> PDFPages = new List<PDFPage>();
PDFPage p1 = new PDFPage();
...
PDFPages.Add(p1);
...
MakePages(PDFPages);
}
Just got flagged as duplicate, so let me ask another: is there a better alternative?
Thanks, John