Editing Document Templates Directly

Editing Document Templates Directly

In the current version of Web Matrix, the only way to modify or add document templates is to edit the appropriate files directly, or place new files into the Web Matrix Templates subfolder hierarchy, and then edit the configuration file.Let’s add a new document template to Web Matrix. First, create a new folder named My New Web Service within Web Matrix’s Web Services folder. In this folder create two subfolders, VB and C#, which correspond to the two languages. In each of these folders create a file named NewFile.asmx (the file name can actually be anything you like, though all the supplied templates use the name NewFile). Then it’s simply a matter of adding the following to the WebMatrix.exe.config file, within the Web Services Templates part of the <documentTypes> section:The <templateDocumentType> element defines the name of the subfolder, the file extension, the category it will appear in within the New File dialog, and the file description. The following screenshot shows this dialog, together with the file that our new template creates:The placeholders for the class and the namespace are enclosed in double percent characters (%%). When the new file is created from the template, the values entered into the Class and Namespace textboxes in the New File dialog are substituted for these placeholders. Of course, the template can contain any code or content that you require – the various Data Pages templates are good examples of this – and you can, if you wish, just edit these rather than adding new ones.

Installing and Using Add-ins and Code Builders

Web Matrix’s extensibility includes both Add-ins and Code Builders, which means that you can supplement the ones provided by default with Web Matrix in order to perform specific tasks that you regularly carry out.An Add-in is a .NET assembly that (usually) has a visual interface, and can be created in Visual Studio .NET using any .NET language. Creating an Add-in isn’t a trivial task, but is easy enough if you are competent with Visual Studio .NET. A detailed tutorial, which describes the requirements and the techniques for constructing and installing an add-in, is available from the Web Matrix community web site.Add-ins can be installed using the Organize Add-ins dialog, where you use the Add Local button to add an assembly. You can also click Add Online and install any of the add-ins available from the ASP.NET Web Matrix site « gallery » page (which we saw when we looked at installing Toolbox components). Once installed, the new add-in will be visible in the Tools menu:

Add-ins can be used to generate code or HTML (perhaps based on a user’s input or other environmental features), create or manipulate disk files, run command-line utilities, or even automate other programs outside the Web Matrix environment. Some of the things that you unfortunately cannot do (at least in the current version) are interact with the Web Matrix IDE, or with contents of the edit windows. However, you can copy text to the clipboard, so that users can paste it into an edit window afterwards.Unlike an add-in, a Code Builder has no visual interface. Instead, it sits in the Code Builders section of the Toolbox, and is used by dragging it onto a page. Like Add-ins, Code Builders are created as .NET assemblies, and are installed by placing the assembly in the CodeBuilders subfolder of the main Web Matrix program folder and adding an appropriate <toolboxItem> element to the <toolbox> section configuration file.

Customizing the Web Matrix Interface

The Classes window and the separate Class Browser tool provide a list of useful Framework classes, from which you can get information about the members of these classes. There are also collapsible folder-based lists of the main ASP.NET classes in the Classes window, which makes it easy to quickly find details of these regularly used classes.The Customize button at the top right of the Classes window can be used to add assemblies that are already in the GAC (Global Assembly Cache), so that the classes they contain are shown in the list. However, this does not modify the collapsible folders of classes, and the modifications you make using the Customize dialog are lost if you delete the WebMatrix.settings file. However, editing the WebMatrix.exe.config configuration file provides a way to change these lists of folders and create new folders, as well as permanently adding classes to the list.

Cours gratuitTélécharger le document complet

Télécharger aussi :

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *