Skip to Main Content
Visual Studio Hacks
book

Visual Studio Hacks

by James Avery
March 2005
Intermediate to advanced content levelIntermediate to advanced
304 pages
19h 23m
English
O'Reilly Media, Inc.
Content preview from Visual Studio Hacks
Generate Code from UML #81
Chapter 10, Work with Visual Studio Tools
|
357
HACK
public string Year;
public virtual void Accelerate( )
{
}
public virtual void Decelerate( )
{
}
public virtual void Drive( )
{
}
public virtual void Start( )
{
}
public virtual void Stop( )
{
}
}// END CLASS DEFINITION Vehicle
As you can see, Visio does an adequate job of generating code for your
classes and can save you an immense amount of time, especially if you have
a class library with a lot of classes that contain a lot of properties.
Hacking the Hack
You’ve seen that Visio does a pretty decent job of generating your class code
right out of the box. But what if you didn’t quite like the way it generated
Figure 10-36. Generated class files in the Solution Explorer
358
|
Chapter 10, Work with Visual Studio Tools
#81 Generate Code from UML
HACK
your code? Or maybe its format is a little off from your own way of writing
code. You can edit and/or create your own code generating templates so
that Visio generates code that way you like it.
To get to the code template editor, click UML
Code Preferences. This
will bring up the Preferences dialog. Several options are found in this dialog,
but for the purposes of this hack, I focus on creating two new templates, one
for your own class template and another for your own property ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft Visual Studio 2015 Unleashed, Third Edition

Microsoft Visual Studio 2015 Unleashed, Third Edition

Mike Snell, Lars Powers
.Net Framework Essentials

.Net Framework Essentials

Thuan L. Thai, Hoang Lam
C# 5.0 Unleashed

C# 5.0 Unleashed

Bart De Smet
Programming .NET Security

Programming .NET Security

Adam Freeman, Allen Jones

Publisher Resources

ISBN: 0596008473Errata Page