
356
|
Chapter 10, Work with Visual Studio Tools
#81 Generate Code from UML
HACK
View the Code
Now that you’ve generated your class code from Visio, go take a look at it.
Go to the location that you chose in the preceding steps. You should see a
folder with the name of your solution. The solution folder will contain a
Visual Studio Solution file as well as a folder with the project name you
specified. For instance, in this example, the solution is named Generate-
CodeFromUML and the project is named VehicleLibrary.
Double-click your generated solution file to open a new instance of Visual
Studio. Chances are the IDE will show the Class1.cs file in the editor. But
wait, you say, I didn’t create a class named
Class1 in Visio. Right you are.
The best I can figure is that this is a small quirk with Visio’s code generator.
You can either ignore this file or just delete it.
The important thing is that you will see a file for each of your classes in the
Solution Explorer, as shown in Figure 10-36.
At this point, you have a fully functional project in Visual Studio; you can
now begin to modify it as needed. But first, take a look at the generated
code. Here is the code for the abstract base class
Vehicle:
// Static Model
public abstract class Vehicle
{
public string Make;
public string Model;
Figure 10-35. The Generate dialog