using System; using System.IO; namespace GenerateTimeStampFile { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() {//Severity Code Description Project File Line Suppression State //Error The command "C:\data\code\ravenqbi\devutil\TimeStamp\TimeStamp.exe" "C:\data\code\ravenqbi\AyaNovaQBI\Timestamp.cs" "/N:AyaNovaQBI"" exited with code 123. AyaNovaQBI string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) { // Assume new file required string fileName = null; string nameSpace = "TimeStamp"; string[] TimestampFile = new string[] {@"using System;", @"// The namespace can be overidden by the /N option:", @"// GenerateTimeStampFile file.cs /N:MyNameSpace", @"// Such settings will override your value here.", @"namespace TimeStamp", @" {", @" /// ", @" /// Static Timestamp related data.", @" /// ", @" /// ", @" /// THIS FILE IS CHANGED BY EXTERNAL PROGRAMS.", @" /// Do not modify the namespace, as it may be overwritten. You can", @" /// set the namespace with the /N option.", @" /// Do not modify the definition of BuildAt as your changes will be discarded.", @" /// Do not modify the definition of TimeStampedBy as your changes will be discarded.", @" /// ", @" public static class Timestamp", @" {", @" /// ", @" /// The time stamp", @" /// ", @" /// ", @" /// Do not modify the definition of BuildAt as your changes will be discarded.", @" /// ", @" public static DateTime BuildAt { get { return new DateTime(???); } } //--**", @" /// ", @" /// The program that time stamped it.", @" /// ", @" /// ", @" /// Do not modify the definition of TimeStampedBy as your changes will be discarded.", @" /// ", @" public static string TimeStampedBy { get { return @""???""; } } //--**", @" }", @" }" }; for (int i = 1; i < args.Length; i++) { if (!args[i].StartsWith("/")) { // File name fileName = args[i]; if (File.Exists(fileName)) { TimestampFile = File.ReadAllLines(fileName); } } else { // It's an option if (args[i].StartsWith("/N:")) { // Set the namespace for the Timestamp class. nameSpace = args[i].Substring(3); } } } if (!string.IsNullOrWhiteSpace(fileName)) { // We have an output location. // Replace the namespace and timestamp. for (int i = 0; i < TimestampFile.Length; i++) { string line = TimestampFile[i].Trim(); if (line.StartsWith("namespace")) { TimestampFile[i] = "namespace " + nameSpace; } else if (line.EndsWith("//--**")) { // Special if (line.Contains("DateTime BuildAt")) { TimestampFile[i] = @" public static DateTime BuildAt { get { return new DateTime(" + DateTime.Now.Ticks.ToString() + @"); } } //--**"; } else if (line.Contains("string TimeStampedBy")) { TimestampFile[i] = @" public static string TimeStampedBy { get { return @""GZTW.AyaNova.BLL.TS""; } } //--**"; } } } File.WriteAllLines(fileName, TimestampFile); } } Environment.ExitCode = 0; //Set no error } } } //using System; //using System.Collections.Generic; //using System.Linq; //using System.Windows.Forms; //namespace TimeStamp //{ // static class Program // { // /// // /// The main entry point for the application. // /// // [STAThread] // static void Main() // { // Application.EnableVisualStyles(); // Application.SetCompatibleTextRenderingDefault(false); // Application.Run(new Form1()); // } // } //}