Added:
net/NantTasks/CheckLicense.cs
Modified:
net/NantTasks/MyTasks.csproj
net/NantTasks/MyTasks.csproj.user
net/NantTasks/MyTasks.suo
Log:
Added checklicense task
Added: net/NantTasks/CheckLicense.cs
===================================================================
--- net/NantTasks/CheckLicense.cs 2005-08-25 16:35:13 UTC (rev 165)
+++ net/NantTasks/CheckLicense.cs 2005-08-26 13:44:25 UTC (rev 166)
@@ -0,0 +1,71 @@
+using System;
+using System.Text;
+using System.IO;
+using System.Globalization;
+using NAnt.Core;
+using NAnt.Core.Types;
+using NAnt.Core.Attributes;
+
+namespace MyTasks
+{
+ /// <summary>
+ /// Summary description for ReplaceTextTask.
+ /// </summary>
+ [TaskName("checklicense")]
+ public class CheckLicenseTask : Task
+ {
+ protected string filename;
+ protected string licenseFile;
+
+ #region Properties
+
+ [TaskAttribute("filetocheck")]
+ public string FileName
+ {
+ get { return filename; }
+ set { filename = value; }
+ }
+
+ [TaskAttribute("licensefile")]
+ public string LicenseFile
+ {
+ get { return licenseFile; }
+ set { licenseFile = value; }
+ }
+
+ #endregion
+
+ protected override void ExecuteTask()
+ {
+ StreamReader fileToCheck = new StreamReader(filename);
+ StreamReader licenseReader = new StreamReader(licenseFile);
+
+ string line = licenseReader.ReadLine();
+ while (line != null)
+ {
+ line = TrimComment(line);
+ string srcline = TrimComment(fileToCheck.ReadLine());
+ if (line != srcline && this.FailOnError)
+ break;
+ line = licenseReader.ReadLine();
+ }
+ licenseReader.Close();
+ fileToCheck.Close();
+ if (line != null)
+ throw new BuildException("File has no/wrong license type",
+ new Location(FileName));
+
+ }
+
+ protected string TrimComment(string line)
+ {
+ if (line.StartsWith("//"))
+ line = line.Substring(2, line.Length-2);
+ else if (line.StartsWith("'"))
+ line = line.Substring(1, line.Length-1);
+ line = line.Trim();
+ return line;
+ }
+
+ }
+}
Modified: net/NantTasks/MyTasks.csproj
===================================================================
--- net/NantTasks/MyTasks.csproj 2005-08-25 16:35:13 UTC (rev 165)
+++ net/NantTasks/MyTasks.csproj 2005-08-26 13:44:25 UTC (rev 166)
@@ -94,6 +94,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "CheckLicense.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "ReplaceTextTask.cs"
SubType = "Code"
BuildAction = "Compile"
Modified: net/NantTasks/MyTasks.csproj.user
===================================================================
--- net/NantTasks/MyTasks.csproj.user 2005-08-25 16:35:13 UTC (rev 165)
+++ net/NantTasks/MyTasks.csproj.user 2005-08-26 13:44:25 UTC (rev 166)
@@ -1,7 +1,7 @@
<VisualStudioProject>
<CSHARP LastOpenVersion = "7.10.3077" >
<Build>
- <Settings ReferencePath = "C:\Program Files\.NET Tools\Nant\bin\" >
+ <Settings ReferencePath = "C:\Program Files\.NET Tools\Nant\bin\;C:\Program Files\Nant\bin\" >
<Config
Name = "Debug"
EnableASPDebugging = "false"
Modified: net/NantTasks/MyTasks.suo
===================================================================
(Binary files differ)
| Thread |
|---|
| • Connector/NET commit: r166 - net/NantTasks | rburnett | 26 Aug |