I am trying to create a form application with customizable "themes" using the abstract factory pattern (just to get some experience with it). I have created an implementation of a theme-factory like this:
public class BlueTheme : IThemeFactory
{
public Button CreateButton() => new BlueButton();
// ... more controls here ...
}
Now I pass an IThemeFactory
instance through the constructor of my Form
:
private IThemeFactory _themeFactory;
public Form1(IThemeFactory theme)
{
_themeFactory = theme; // e.g. new BlueTheme()
InitializeComponent();
}
My question is: Are there ways make my form use the IThemeFactory.CreateButton()
method to generate all of the buttons on the form?
Aucun commentaire:
Enregistrer un commentaire