Click here to Skip to main content
15,879,474 members
Articles / Desktop Programming / Windows Forms

NLog Log and Audit Advanced Target

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
26 May 2010CPOL6 min read 42.4K   750   35  
A way to audit your business objects using NLog.
using System;
using System.Collections.Generic;
using System.Reflection;
using System.IO;

namespace App.Logger.Targets.ObjectHistoryLogger.Data.DBScripts
{
	/// <summary>
	/// Comparer to sort the script files by name & version
	/// </summary>
	internal class ScriptFileNameComparer : IComparer<string>
	{
		#region IComparer<string> Members

		public int Compare(string x, string y)
		{
			string type1 = x.Split('-')[0].ToLower();
			Version version1 = new Version(x.Split('-')[1].Trim().ToLower().Replace("v", ""));
			string type2 = y.Split('-')[0].ToLower();
			Version version2 = new Version(y.Split('-')[1].Trim().ToLower().Replace("v", ""));

			if (type1.Equals(type2))
			{
				return version1.CompareTo(version2);
			}
			else
			{
				return 0;
			}
		}

		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Switzerland Switzerland
Senior IT Consultant working in Switzerland as Senior Software Engineer.

Find more at on my blog.

Comments and Discussions