I am trying to make a library for MigraDoc, based on this example, which supports different types of documents. My idea was to make a base class, with a virtual method for CreatePage()
(the method responsible for the page layout). However, the concept was that CreatePage()
should be called from a method called CreateDocument()
which is called by the user. Alas, it will be possible to override CreatePage()
, but it is not meant to be called directly. It will look something like this:
public class DocumentWriter
{
private Document document;
public virtual void CreateDocument(IDocumentArgs args)
{
document = new Document();
DefineStyles();
CreatePage();
FillContent(args);
}
public virtual void CreatePage()
{
// Create page layout here
}
// Remaining code skipped for readability...
}
But if create inherited class, which overrides CreatePage()
, then which method will be called from CreateDocument()
?
- The original virtual (non-overridden) method
- The method which overrides
CreatePage()