Tuesday, January 21, 2014

A custom exception class with Log flag

A class to re-thrown Exception with property if the Exception is already logged.

[Serializable()] public class ExceptionLog : Exception { private bool isLogged; public bool IsLogged { get { return isLogged; } } protected ExceptionLog() : base() { } public ExceptionLog(bool value) : base() { isLogged = value; } public ExceptionLog(bool value, string message) : base(message) { isLogged = value; } public ExceptionLog(bool value , string message , Exception innerException) : base(message, innerException) { isLogged = value; } protected ExceptionLog(SerializationInfo info , StreamingContext context) : base(info, context) { } }

Share/Bookmark

Friday, January 3, 2014

Split Camel Case "string" To Human Readable

private string SplitCamelCaseToHumanReadable(string strCamelCase) { var rgx = new Regex( @"(?<=[A-Z])(?=[A-Z][a-z]) | (?<=[^A-Z])(?=[A-Z]) | (?<=[A-Za-z])(?=[^A-Za-z])" , RegexOptions.IgnorePatternWhitespace); return rgx.Replace(strCamelCase, " "); }

Share/Bookmark