generate barcode in crystal report EXTENDING NANT in Font

Maker Code 39 Full ASCII in Font EXTENDING NANT

CHAPTER 7 EXTENDING NANT
Create Code-39 In None
Using Barcode drawer for Font Control to generate, create Code 39 Extended image in Font applications.
www.OnBarcode.com
Printing USS Code 39 In None
Using Barcode printer for Font Control to generate, create Code39 image in Font applications.
www.OnBarcode.com
The NAnt source code consists of 14 projects at the time of writing. The most important to us is the NAnt.Core project, which as you will be able to see from Figure 7-1 contains many familiar-sounding class names in terms of their similarity to actual NAnt task names. The other projects are largely related to specific task types, such as Visual Studio .NET.
Make UPC-A Supplement 5 In None
Using Barcode creator for Font Control to generate, create UPC A image in Font applications.
www.OnBarcode.com
DataMatrix Creation In None
Using Barcode encoder for Font Control to generate, create Data Matrix ECC200 image in Font applications.
www.OnBarcode.com
Figure 7-1. The NAnt.Core project Those classes in the root of this project form the framework to NAnt: the project, target, and task classes, for example. These are of course far from the full picture, and there are a whole host of supporting structures. In the subfolders of the project are additional classes to support the framework. The subfolders contain the following:
Making Barcode In None
Using Barcode creator for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
Code 128 Code Set B Encoder In None
Using Barcode creation for Font Control to generate, create Code-128 image in Font applications.
www.OnBarcode.com
CHAPTER 7 EXTENDING NANT
UCC - 12 Printer In None
Using Barcode printer for Font Control to generate, create UCC.EAN - 128 image in Font applications.
www.OnBarcode.com
Generating ITF In None
Using Barcode maker for Font Control to generate, create ANSI/AIM I-2/5 image in Font applications.
www.OnBarcode.com
Attributes. These supporting classes allow a simple and effective way of providing the XML structure and validation to a new task. We will make use of these, and see them in action when we explore the tasks. Filters. These support the use of filtersets for token replacement and so on, a relatively new feature in NAnt. Functions. Similarly, these classes provide the function capabilities of NAnt, another relatively new feature. Resources. Currently contains only the projecthelp.xslt file. Tasks. Contains several of the general-purpose tasks for NAnt. We will look at some of these later. They are a great starting point for considering a new task. Types. Another set of supporting classes for tasks. These are the types we discussed back in 3 elements with specific functionality such as FileSet. We will make use of these too. Util. Contains some additional supporting classes, particularly command-line parsing support. A simplified view of the relationships between the classes we are interested in for task creation is shown in Figure 7-2.
Generating USS Code 39 In None
Using Barcode maker for Online Control to generate, create Code 39 Extended image in Online applications.
www.OnBarcode.com
Paint ANSI/AIM Code 39 In Visual C#
Using Barcode creation for .NET framework Control to generate, create Code39 image in .NET framework applications.
www.OnBarcode.com
Element
Decode ANSI/AIM Code 39 In C#.NET
Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Painting ANSI/AIM Code 39 In Objective-C
Using Barcode maker for iPad Control to generate, create Code 3/9 image in iPad applications.
www.OnBarcode.com
+Project +Parent
Barcode Creation In None
Using Barcode creator for Software Control to generate, create Barcode image in Software applications.
www.OnBarcode.com
PDF 417 Creator In None
Using Barcode generation for Microsoft Excel Control to generate, create PDF-417 2d barcode image in Microsoft Excel applications.
www.OnBarcode.com
Task
Barcode Generation In Visual Studio .NET
Using Barcode printer for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
Barcode Creation In Objective-C
Using Barcode printer for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
+ExecuteTask()
Draw Code39 In None
Using Barcode maker for Online Control to generate, create Code 39 Extended image in Online applications.
www.OnBarcode.com
Generate DataMatrix In Objective-C
Using Barcode maker for iPad Control to generate, create ECC200 image in iPad applications.
www.OnBarcode.com
DataTypeBase
Encode Data Matrix 2d Barcode In Java
Using Barcode drawer for Java Control to generate, create Data Matrix ECC200 image in Java applications.
www.OnBarcode.com
Make QR-Code In Visual Studio .NET
Using Barcode maker for .NET framework Control to generate, create QR image in VS .NET applications.
www.OnBarcode.com
Target +Dependencies +Execute()
ExternalProgramBase
+ProgramFileName +ExecuteTask() +ProgramArguments()
MkDirTask +ExecuteTask()
FileSet
ExecTask
Figure 7-2. Simplified class diagram for NAnt
CHAPTER 7 EXTENDING NANT
A significant amount of work occurs in the project class related to the loading of the script file and the organization of the elements within the project. The element class itself then handles a lot of common functionality and manages references to parents and the main project. The use of attributes to mark up an individual class with XML structural details also avoids more plumbing code. Therefore, when creating a NAnt task, the code is generally very efficient. The concentration is on the code to complete the task rather than the integration of the task into the NAnt framework. We can explore this further now.
Investigating NAnt Tasks: <mkdir>
A look through any of the code for NAnt tasks will reveal many similarities. The first thing to notice is the many attributes used throughout the classes. These are the required items of code that ensure the integration of the task into the framework other than the inheritance of the Task class itself.
A Look at <mkdir>
The <mkdir> task is a good place to start in terms of seeing a simple task integrated into the framework. The code for the <mkdir> task is as follows: using System; using System.Globalization; using System.IO; using NAnt.Core.Attributes; using NAnt.Core.Util; namespace NAnt.Core.Tasks { [TaskName("mkdir")] public class MkDirTask : Task { private DirectoryInfo _dir; [TaskAttribute("dir", Required=true)] public DirectoryInfo Dir { get { return _dir; } set { _dir = value; } } protected override void ExecuteTask() { try { if (!Dir.Exists) { Log(Level.Info, "Creating directory '{0}'.", Dir.FullName); Dir.Create(); } } catch (Exception ex) {
CHAPTER 7 EXTENDING NANT
throw new BuildException(string.Format(CultureInfo.InvariantCulture, "Directory '{0}' could not be created.", Dir.FullName), Location, ex); } } } } As you can see, the creation of the task is straightforward. In this instance the task is simple, but despite this, you might expect to have a more complicated method of integration than is demonstrated here. This is one of the core strengths of the NAnt code: it is easily and readily extensible. The items in bold are worth considering in more detail. The TaskName attribute is used at the class level to define the name of the element as it will appear in a build file <mkdir>. The class then inherits from the Task class, which means that it will need to override the ExecuteTask method. In order to complete the function of folder creation (the purpose of <mkdir>), the task needs to know the folder it must create. To expose the public property to the build file, another attribute is used. In this case TaskAttribute describes the name of the attribute and also includes a simple validation to ensure that the attribute is included when using the task (Required=true). The ExecuteTask method can then be written as needed. The main point to notice in this simple method is the catch and rethrow of an exception as a BuildException. This is a convention through all task code. This code allows us to use the <mkdir> task in build files as such this: <mkdir dir="${core.source}\" failonerror="false"/> Note that the failonerror, if, and unless attributes are all part of the base Task implementation and so behave in the same way across all tasks.
Copyright © OnBarcode.com . All rights reserved.