Results 1 to 8 of 8

Thread: [RESOLVED] [2005] Generator for Singleton code

  1. #1

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Resolved [RESOLVED] [2005] Generator for Singleton code

    In the Designer of my forms I usually have this for Singleton purposes.

    C# Code:
    1. private static frmMainMenu  instance = null;
    2. public static frmMainMenu Instance()
    3. {
    4.     if (instance == null)
    5.     {
    6.         instance = new frmMainMenu();
    7.     }
    8.     return instance;
    9. }
    10. /// <summary>
    11. /// Clean up any resources being used.
    12. /// </summary>
    13. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    14. protected override void Dispose(bool disposing)
    15. {
    16.     if (disposing && (components != null))
    17.     {
    18.         components.Dispose();
    19.     }
    20.     base.Dispose(disposing);
    21.     instance = null;
    22. }

    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.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  2. #2
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    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.

  3. #3

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    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?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  7. #7

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [RESOLVED] [2005] Generator for Singleton code

    Snippet it is.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: [2005] Generator for Singleton code

    Quote 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.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width