By Ian Griffiths, Jon Flanders, Chris Sells
Price: $39.95 USD
£28.50 GBP
Cover | Table of Contents | Colophon
#include the header files and link in the
.lib files.) For COM components, either
#include the appropriate header files or use the
#import directive on the relevant type library.
targetSchema. Visual Studio .NET uses this
property to work out how to validate the document. It also uses it to
determine which elements to display in IntelliSense member lists.
Form
class and an ASP.NET .aspx file. Of course,
Visual Studio .NET will let you edit these files as text, but it is
also able to provide a design view. A design view displays how the
user interface will look at runtime (or a reasonable approximation of
it) and allows it to be edited visually using drag and drop.System.ComponentModel.Component.)
DataSet class from an XML schema file
(.xsd). (See Chapter 5 for
more information on type-safe DataSet wrappers.)
However, this system is extensible, allowing you to add your own
custom tools to generate code.IVsSingleFileGenerator COM interface. The main
interesting method on this interface is Generate.
VS.NET will call this each time the source file is saved, passing in
the filename and the contents of the input file. The
Generate method returns an array of bytes that
will contain either C#, J#, or Visual Basic .NET source code,
depending on the type of project. VS.NET saves these bytes to a file,
which it compiles when the project is next built. (You can see this
file in the Solution Explorer by pressing the Show All Files button.)
Because the generated file is compiled as part of the project,
IntelliSense will be available during development time for all of the
types it defines.IVsSingleFileGenerator COM interface directly, a
managed base class provided in Visual Studio .NET
2002—Microsoft.VSDesigner.CodeGenerator.BaseCodeGeneratorWithSite—is
much easier to use. To use it, just import the
Microsoft.VSDesigner.dll assembly in the
Common7\IDE directory of the VS.NET program
directory. Your class must be decorated with the
Guid attribute to determine its CLSID, but apart
from that, the only thing you have to do is write the
Generate method itself. The following code shows
the implementation of a simple code generator.[Guid("A0B5E5E9-3DF8-48bc-A6BA-E0DFD35C6237")]
public class MyGenerator : BaseCodeGeneratorWithSite
{
public override byte[ ] GenerateCode(string file, string contents)
{
string code = "public class Foo { }";
return System.Text.Encoding.ASCII.GetBytes(code);
}
}
this, illustrates that the watch
window allows objects to be expanded so that the individual fields
can be shown. The second expression, ((Button)
sender).Text, illustrates that we are not restricted to
simple variable names—this is a snippet of C# that performs a
cast on a variable and then retrieves a property.
. . . cmd.CommandType = CommandType.StoredProcedure; IDataReader dr = cmd.ExecuteReader( ); . . .
|
Project template
|
Managed
|
Description
|
Output
|
|---|---|---|---|
|
ASP.NET Web Application (C#/VB/J#)
|
Yes
|
ASP.NET Web Forms Application
|
Managed DLL and content files
|
|
ASP.NET Web Service (C#/VB/J#/MC++)
|
Yes
|
|
Project template
|
Managed
|
Description
|
Output
|
|---|---|---|---|
|
ASP.NET Web Application (C#/VB/J#)
|
Yes
|
ASP.NET Web Forms Application
|
Managed DLL and content files
|
|
ASP.NET Web Service (C#/VB/J#/MC++)
|
Yes
|
ASP.NET Web Service
|
Managed DLL and content files
|
|
ASP.NET Mobile Web Application
|
Yes
|
ASP.NET Web Forms Applications for mobile devices
|
Managed DLL and content files
|
|
Empty Web Project (C#/VB/J#)
|
Yes
|
An empty project to which to add source and content files
|
Managed DLL and content files
|
|
ATL Server
(VC++)
|
System.Web.Mobile.) For ASP.NET Web Service
projects, the main file is Service1.asmx, which
acts as the main web service entry point. An Empty Web Project
contains no files at all to start with.