// NAnt - A .NET build tool
// Copyright (C) 2001-2004 Gerry Shaw
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Gert Driesen (gert.driesen@ardatis.com)
using System;
using System.Reflection;
using NAnt.Core;
using NAnt.Core.Attributes;
namespace NAnt.Core.Functions {
[FunctionSet("version", "Version")]
public class VersionFunctions : FunctionSetBase {
#region Public Instance Constructors
public VersionFunctions(Project project, PropertyDictionary properties) : base(project, properties) {
}
#endregion Public Instance Constructors
#region Public Static Methods
///
/// Gets the value of the major component of a given version.
///
/// A version.
///
/// The major version number.
///
///
///
///
[Function("get-major")]
public static int GetMajor(Version version) {
return version.Major;
}
///
/// Gets the value of the minor component of a given version.
///
/// A version.
///
/// The minor version number.
///
///
///
///
[Function("get-minor")]
public static int GetMinor(Version version) {
return version.Minor;
}
///
/// Gets the value of the build component of a given version.
///
/// A version.
///
/// The build number, or -1 if the build number is undefined.
///
///
///
///
[Function("get-build")]
public static int GetBuild(Version version) {
return version.Build;
}
///
/// Gets the value of the revision component of a given version.
///
/// A version.
///
/// The revision number, or -1 if the revision number is undefined.
///
///
///
///
[Function("get-revision")]
public static int GetRevision(Version version) {
return version.Revision;
}
/*
///
/// Initializes a new instance using the value
/// represented by the specified .
///
/// A string containing the major, minor, build, and revision numbers, where each number is delimited with a period character ('.').
///
/// A instance representing the specified
/// .
///
/// has fewer than two components or more than four components.
/// A major, minor, build, or revision component is less than zero.
/// At least one component of does not parse to a decimal integer.
[Function("init")]
public static Version Init(string version) {
return new Version(version);
}
*/
#endregion Public Static Methods
}
[FunctionSet("version", "Conversion")]
public class VersionConversionFunctions : FunctionSetBase {
#region Public Instance Constructors
public VersionConversionFunctions(Project project, PropertyDictionary properties) : base(project, properties) {
}
#endregion Public Instance Constructors
#region Public Static Methods
///
/// Converts the specified string representation of a version to
/// its equivalent.
///
/// A string containing the major, minor, build, and revision numbers, where each number is delimited with a period character ('.').
///
/// A instance representing the specified
/// .
///
/// has fewer than two components or more than four components.
/// A major, minor, build, or revision component is less than zero.
/// At least one component of does not parse to a decimal integer.
[Function("parse")]
public static Version Parse(string version) {
return new Version(version);
}
///
/// Converts the specified to its equivalent
/// string representation.
///
/// A to convert.
///
/// The string representation of the values of the major, minor, build,
/// and revision components of the specified .
///
///
///
///
[Function("to-string")]
public static string ToString(Version value) {
return value.ToString();
}
#endregion Public Static Methods
}
}