473,729 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tool to generate properties from private fiels

Anyone know a free vs.net 2003 plugin that is capable of generating
properties from private fields for C#? Thanks ahead.

Jan 16 '06 #1
3 1400
Thanks a lot.

Jan 16 '06 #3
Truong Hong Thi wrote:
Anyone know a free vs.net 2003 plugin that is capable of generating
properties from private fields for C#? Thanks ahead.


Use my macro below and bind it to a keycombi, e.g cntrl-shift + n

say you have the field:
private string _foo;

you then type:
string foo

and on that line hit cntrl-shift-n

and you'll get
<summary>Gets / Sets Foo</summary>
public string Foo
{
get { return _foo;}
set { _foo = value;}
}
''' Creates a property.
''' format: type name has to be present at the current line.
''' Uses caMel casing.
Sub CreateProperty( )
Dim typeName, propertyName, memberName, nameRead As String
Dim ts As TextSelection
Dim sb As New StringBuilder
Dim boolIsOpened As Boolean

Try
ts = DTE.ActiveDocum ent.Selection
If (ts.IsEmpty) Then
ts.SelectLine()
End If

typeName = (ts.Text.Split( " ")(0)).Trim ()
nameRead = ((ts.Text.Split (" ")(1))).Tri m()
propertyName = nameRead.Substr ing(0, 1).ToUpper &
nameRead.Substr ing(1)
memberName = "_" + nameRead.Substr ing(0, 1).ToLower() &
nameRead.Substr ing(1)

' actual property
sb.Append("/// <summary>" & Environment.New Line)
sb.AppendFormat ("/// Gets / sets {0}{1}", nameRead,
Environment.New Line)
sb.Append("/// </summary>" & Environment.New Line)
sb.Append("publ ic " + typeName + " " + propertyName)
sb.Append(vbCrL f)
sb.Append("{")
sb.Append(vbCrL f)

' get
sb.Append("get" )
sb.Append(vbCrL f)
sb.Append("{")
sb.Append(vbCrL f)
sb.AppendFormat ("return {0};", memberName)
sb.Append(vbCrL f)
sb.Append("}")
sb.Append(vbCrL f)

' set
sb.Append("set" )
sb.Append(vbCrL f)
sb.Append("{")
sb.Append(vbCrL f)
sb.AppendFormat ("{0} = value;", memberName)
sb.Append(vbCrL f)
sb.Append("}")
sb.Append(vbCrL f)
sb.Append("}")
sb.Append(vbCrL f)
sb.Append(vbCrL f)

'Check to see if UndoContext object is already open.
If DTE.UndoContext .IsOpen = False Then
'Open the UndoContext object to track changes.
Call DTE.UndoContext .Open("CreatePr operty " &
propertyName, False)
boolIsOpened = True
End If

' Replace the text
ts.Delete()
ts.Insert(sb.To String(),
vsInsertFlags.v sInsertFlagsIns ertAtStart)
Finally

'If UndoContext was already open, don't close it.
If boolIsOpened = True Then
'Close the UndoContext object to commit the changes.
DTE.UndoContext .Close()
' Format the Selection
ts.SmartFormat( )
ts.MoveToPoint( ts.BottomPoint. CreateEditPoint ())
ts.LineUp()
End If
End Try
End Sub

Frans
--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Jan 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2351
by: P Jones | last post by:
Hi, I support an enterprise web application (IE client) built in VB6, with about 200 classes, serving about 7000 users, running on 3 clustered servers. I need to incorporate web reporting for the first time, so I am interested in learning what web reporting options are out there, and the pros and cons of each. In general I need to generate reports with XML documents as inputs, and make them available to all web users. I am partial...
26
2968
by: temp | last post by:
Hi, My boss is asking me to generate a column mapping report of all the queries. Basically, we get our data from ORACLE. There's a queary that create new table from ORACLE tables. Then, there are reports and queries that uses the new table. Is there an add in or tool that can generate mapping reports of the queries.
8
5817
by: Bill Rust | last post by:
I've created an "Add Item" wizard for VB.NET 2003 that allows a user to add a specialized class that works with my application framework. In the wizard, the user can select the interfaces they would like to support. During the code generation phase, I add an "Implements Ixxx" for each interface they select, but I've not yet figured out how to add the skeleton implementation for those interfaces. Once the user opens the class in the VS...
7
7000
by: George Jordanov Ivanov | last post by:
Folks, I have to design the WSDL files of a bunch of XML Web Services. But, unfortunately, I am not very keen on writing the WSDL file line by line, and moreover be aware of the whole standard specification in details. I will be very happy if there is a visual tool, which can do this for me. Does anyone know such kind of tool (if it is free, this is going to be awesome)? Thanks in advance. Regards,
0
5113
by: Richard Gregory | last post by:
Hi, I have the wsdl below, for an Axis web service, and when I select Add Web Refernce in Visual Studio the proxy is missing a class representing the returnedElementsType (see reference.cs below the wsdl). This complex type is a collection of another complex type(elementType), and the Reference.cs has an array of these rather than the single returnedElementsType. If If I want to be able to obtain these elements from the SOAP response I...
4
2379
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for my own tool (http://openswarm.sourceforge.net). I already started restructuring my code to separate the actual command implementations from the command-line scripts (which is optparser-based now) and have some ideas how to proceed. But probably...
3
1362
by: Anibal Caixinha | last post by:
Hello, I'm trying to create a task manager , for accounting firm, they have a series of regular tasks they need to be able to control , research old records,etc... The problem is that all of these tasks have a common set of fields ,the problem is that some of them have some specific fiels (most of them just text fields). Has anyone developed a similar system and/or can give some hints on how I can alow the user to generate these fields on...
2
1793
by: vips | last post by:
I am trying to generate a proxy class from a WSDL contract file that has nested levels of elements/attribute groups. It seems the WSDL.exe tool only reads upto a certain nesting level and then it starts ignoring the elements/attributes that are further referenced using the 'ref' keyword in the schema types. Is it a known limitation of WSDL tool? If it is a known limitation, is there any workaround or any other tool that can generate the...
7
1335
by: =?Utf-8?B?TXJOb2JvZHk=?= | last post by:
I am used to using Java's Eclipse IDE where I can choose one or more fields and have the IDE automatically generate getter and setter methods for it. Is there something in the Visual Studio IDE where I can select a field like "string name;" and automatically generate a Property for it?
0
8770
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9440
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9299
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9174
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6029
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4541
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4800
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3251
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2174
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.