In a typical winform program.cs contains the entry point:
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // the code goes on
I want to create my own framework which hide the plumbings of all stuffs that has nothing to do with application domain so I’d like to be able to create a base class in an another namespace something like this
namespace MyFramework
{
public partial class Program
{
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// the code goes on
And then in my app namespace program.cs inherit from the one above so that I can get rid off the Application.EnableVisualStyles and write only something like this
static void Main(string[] args): base()
{
//only app domain code
I can inherit from base class if I remove static attrib from both class but I am not able to remove static from main entry method so I cannot really finalize.
I don’t want to use code behind to hide the plumbings because I need to port this to other languages that doesn’t have code behind.
So is there a way to achieve this simple and legitimate goal with OOP (inheritance or not, static or not) only without using some big external framework ?
For example is there a way I could delegate main entry point to another class in the framework namespace ?
The entry point method needs to be static so using inheritance (as perceived by you) would not work but there can be several ways to do what you want to do. For example,
Now, you can use it
Yet another inheritance based variation would be
And you will use it as follows: