private string UpdateVersionProperty(string versionNumber, IncrementMethod method, string value, string format, string logMessage) { this.Log.LogMessage(MessageImportance.Low, "\tUpdate method is {0}", method.ToString()); if (string.IsNullOrEmpty(format)) { format = "0"; } switch (method) { case IncrementMethod.NoIncrement: if (value == null) { return versionNumber; } this.Log.LogMessage(MessageImportance.Low, logMessage, value); return value; case IncrementMethod.AutoIncrement: int newVersionNumber = int.Parse(versionNumber, CultureInfo.InvariantCulture); newVersionNumber++; this.Log.LogMessage(MessageImportance.Low, logMessage, newVersionNumber.ToString(format, CultureInfo.InvariantCulture)); return newVersionNumber.ToString(format, CultureInfo.InvariantCulture); case IncrementMethod.DateString: string newVersionNumber1 = this.UseUtc ? DateTime.UtcNow.ToString(format, CultureInfo.InvariantCulture) : DateTime.Now.ToString(format, CultureInfo.InvariantCulture); this.Log.LogMessage(MessageImportance.Low, logMessage, newVersionNumber1); return newVersionNumber1; case IncrementMethod.Julian: string newVersionNumber2 = this.UseUtc ? DateTime.UtcNow.ToString(format, CultureInfo.InvariantCulture) : DateTime.Now.ToString("yy", CultureInfo.InvariantCulture); newVersionNumber2 += DateTime.Now.DayOfYear.ToString("000", CultureInfo.InvariantCulture); this.Log.LogMessage(MessageImportance.Low, logMessage, newVersionNumber2); return newVersionNumber2; case IncrementMethod.YearWeekDay: DateTime now = this.UseUtc ? DateTime.UtcNow : DateTime.Now; string newVersionNumber3 = now.ToString("yy", CultureInfo.InvariantCulture); newVersionNumber3 += CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(now, CalendarWeekRule.FirstDay, (DayOfWeek)Enum.Parse(typeof(DayOfWeek), this.FirstDayOfWeek)).ToString("D2", CultureInfo.InvariantCulture); newVersionNumber3 += ((int)now.DayOfWeek).ToString(CultureInfo.InvariantCulture); Log.LogMessage(MessageImportance.Low, logMessage, newVersionNumber3); return newVersionNumber3; case IncrementMethod.ElapsedDays: DateTime now2 = this.UseUtc ? DateTime.UtcNow : DateTime.Now; TimeSpan elapsed = now2 - Convert.ToDateTime(this.StartDate); return elapsed.Days.ToString(CultureInfo.CurrentCulture).PadLeft(this.PaddingCount, this.PaddingDigit); default: return string.Empty; } }
private string UpdateVersionProperty(string versionNumber, IncrementMethod method, string value, string format, string logMessage) { this.Log.LogMessage(MessageImportance.Low, "\tUpdate method is {0}", method.ToString()); if (string.IsNullOrEmpty(format)) { format = "0"; } switch (method) { case IncrementMethod.NoIncrement: if (value == null) { return versionNumber; } this.Log.LogMessage(MessageImportance.Low, logMessage, value); return value; case IncrementMethod.AutoIncrement: int newVersionNumber = int.Parse(versionNumber, CultureInfo.InvariantCulture); newVersionNumber++; this.Log.LogMessage(MessageImportance.Low, logMessage, newVersionNumber.ToString(format, CultureInfo.InvariantCulture)); return newVersionNumber.ToString(format, CultureInfo.InvariantCulture); case IncrementMethod.DateString: string newVersionNumber1 = this.UseUtc ? DateTime.UtcNow.ToString(format, CultureInfo.InvariantCulture) : DateTime.Now.ToString(format, CultureInfo.InvariantCulture); this.Log.LogMessage(MessageImportance.Low, logMessage, newVersionNumber1); return newVersionNumber1; default: return string.Empty; } }