In the Designer of my forms I usually have this for Singleton purposes.
C# Code:
private static frmMainMenu instance = null; public static frmMainMenu Instance() { if (instance == null) { instance = new frmMainMenu(); } return instance; } /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); instance = null; }
Is there any hack in the IDE that would let me just press a button or something and it will automatically add the code I have above to the selected Designer?
I can always type or copy/paste/modify it but I thought there could be something that I could set to just automate this redundant task.




Reply With Quote