Visual Studio automatic coding plug-in (Autocode--devprojects.net)

Source: Internet
Author: User

Today, I have discovered a VS plug-in, which has good functions and is recommended to you. Official http://www.devprojects.net/

Provides the following functions:

Smart sensing new!
To call a Quick Command, press Ctrl + press Enter.
Code generation using the same syntax as T4 and ASPX
Edit code snippets in Visual Studio Editor
Full access to Visual Studio automation objects
FileCodeModel access, SmartFormat, code substitution, cursor location
Over 100 useful commands
 

Demonstration images on the official website (there is a flash on the official website, which is more detailed, but the CSDN blog does not seem to be available)

CSDN download (including VS2008, 2010,11 installation package): http://www.bkjia.com/uploadfile/2012/0525/20120525113140735.rar


The default shortcut after installation is ctrl + enter.
 
 

Start to use automatic Encoding
This section describes how to use automatic encoding. In this walkthrough, We will generate some properties of a class and be familiar with automatic coding to generate embedded code.

Create a new console application project
Place the cursor at the bottom of the class, just like the code below.

Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
 
Namespace ConsoleApplication1
{
Class Program
{
Static void Main (string [] args)
{
}
}
| <---- Set the cursor here
}
 

Call the automatic encoding command input dialog box

Press Ctrl + Enter to Enter the dialog box. Written in "int id string name Person class ".

 

After you press enter, the class Person generates the property ID and Name, as shown below:

Namespace ConsoleApplication1
{
Class Program
{
Static void Main (string [] args)
{
}
}
 
Public class Person
{
Private int _ id;
Private string _ name;
 
Public Person ()
{
}
 
Public int Id
{
Get {return _ id ;}
Set {_ id = value ;}
}
Public string Name
{
Get {return _ name ;}
Set {_ name = value ;}
}
|
}
 
}

Enable Automatic encoding embedding
You can also directly call the editor.

Enter "string LastName p" and press Ctrl + Enter.

Public string Name
{
Get {return _ name ;}
Set {_ name = value ;}
}
String lastName p
This will execute the get/set attribute generated by the "attribute" command.

Private string _ lastName;
Public string LastName
{
Get {return _ lastName ;}
Set {_ lastName = value ;}
} Command PropertyAutomatic (PA)
This command will generate an automatic attribute. Enter string phone pa and press Ctrl + Enter to generate the following code:

Public string Phone {get; set;} command PropertyIf (PIF)
This command will generate an attribute that is empty when the Instance value is

Enter Address HomeAddress pif and press Ctrl + Enter to produce the following code:

Public Address HomeAddress
{
Get
{
If (_ homeAddress = null)
{
_ HomeAddress = CreateHomeAddress ();
}
Return _ homeAddress;
}
} Rewrite the ToString method.
Now let's rewrite the ToString method to return the format representation of a class attribute.

 

Set the cursor and execution in the classTostrCommand.

This will override the ToString () method in our class.
Override public string ToString ()
{
String str = String. Empty;
Str = String. Concat (str, "Id =", Id, "\ r \ n ");
Str = String. Concat (str, "Name =", Name, "\ r \ n ");
Str = String. Concat (str, "LastName =", LastName, "\ r \ n ");
Return str;

 

} Instantiate the Person class
Let's use another command to instantiate the default value of the class.

Main method,

Enter Person ci and press Ctrl + Enter to produce the following code:

 

Class Program
{
Static void Main (string [] args)
{
Person person = new Person ();
Person. Id = 9999;
Person. Name = "Name ";
Person. LastName = "LastName ";
}
}
Of course there are many other shortcut keys:

(1) if else shortcut, directly enter ife and press ctrl + enter

(2) For the if shortcut, enter if directly, and press ctrl + enter (in fact, the one that comes with VS is also good. directly enter it and press the tab key)

(3) create a constructor, enter c in a class, and press ctrl + enter

(4) create a private member, <Class Name> <member name> f, and press ctrl + enter

(5) create a method, <type> <Method Name> m, and press ctrl + enter

(6) create a private method, <type> <Method Name> mp, and press ctrl + enter

(7) create a static method, <type> <Method Name> MS, and then press ctrl + enter

(8) create a private method, <type> <Method Name> msp, and press ctrl + enter

(9) only create attributes without creating corresponding members and only get, enter <type> <member name> pm in the class, and press ctrl + enter

(10) create a get-only property and its members, <type> <member name> p g, and press ctrl + enter

(11) Create attributes and members with both get and set, <type> <member name> p, and press ctrl + enter

(12) instantly write Console. WriteLine ();, <content to be output> cw, then press ctrl + enter

(13) try catch. enter tc and press ctrl + enter.

(14) try catch final shortcut, enter tcf directly, and press ctrl + enter

......

There are many other features to be found. Remember to share them.

 

 

Author tu jiankai
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.