|
-
Jan 26th, 2009, 03:42 PM
#1
[RESOLVED] [2005] Generator for Singleton code
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.
-
Jan 26th, 2009, 03:50 PM
#2
Re: [2005] Generator for Singleton code
Any reason you can't create a snippet? You should be able to add the code in a couple of keystrokes going that route.
-
Jan 26th, 2009, 03:57 PM
#3
Re: [2005] Generator for Singleton code
Hmmmnn... Okay. I think I tried that previously but was unsuccessful in creating a snippet. Do you have some direction that I could follow?
-
Jan 26th, 2009, 04:02 PM
#4
Re: [2005] Generator for Singleton code
Do you mean creating code snippets in general? If so try this http://msdn.microsoft.com/en-us/libr...93(VS.80).aspx
-
Jan 26th, 2009, 04:08 PM
#5
Re: [2005] Generator for Singleton code
I will try it again when I have more time, I think I have tried it last year but failed and didn't bother with it again. Thanks guys! Will let you know when I am done with it.
-
Jan 26th, 2009, 04:14 PM
#6
Re: [2005] Generator for Singleton code
How should I design the snippet so it will take the name of the form that is currently selected?
-
Feb 4th, 2009, 01:44 AM
#7
Re: [RESOLVED] [2005] Generator for Singleton code
-
Feb 4th, 2009, 03:36 PM
#8
Re: [2005] Generator for Singleton code
 Originally Posted by dee-u
How should I design the snippet so it will take the name of the form that is currently selected?
This thread has the answer in case someone else is interested.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|