Click here to Skip to main content
15,886,069 members
Articles / Desktop Programming / WPF

Zip My Code

Rate me:
Please Sign up or sign in to vote.
4.78/5 (17 votes)
20 Dec 2009CPOL3 min read 71.6K   2K   48  
A utility stripping your source code to the essential core and then compressing it to a nice CodeProject article attachment.
using ZipMyCode.Properties;
using ZipMyCode.UI.Mvvm.Validation;

namespace ZipMyCode.UI.ExcludeItem
{
	/// <summary>
	/// Rule validating that a string is not null or empty.
	/// </summary>
	class NotNullOrEmptyValidationRule : IValidationRule
	{
		/// <summary>
		/// Validates a value.
		/// </summary>
		/// <param name="value">The value to validate.</param>
		/// <returns>true if validation is successful; otherwise false.</returns>
		public bool Validate(object value)
		{
			string valueText = value as string;

			if (string.IsNullOrEmpty(valueText))
			{
				ErrorMessage = Resources.NotNullValidationRule_Error;
				return false;
			}

			ErrorMessage = string.Empty;
			return true;
		}


		/// <summary>
		/// Gets the error message if validation fails; otherwise an empty string ("").
		/// </summary>
		public string ErrorMessage { get; private set; }
	}
}

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
Software Developer Axis Communications
Sweden Sweden
Got my first computer in the 90's and loved it even though it sounded like a coffeemaker.

Now getting paid for designing cool applications, and drinks the coffee instead of listening to it being made.

Comments and Discussions