This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Utilities | |
{ | |
/// <summary> | |
/// Classed used to distinguish validation exceptions from standard argument or application exceptions | |
/// </summary> | |
public class ValidationException : ArgumentException | |
{ | |
public ValidationException() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.ComponentModel.DataAnnotations; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
using System.Text.RegularExpressions; | |
using Utilities.Extensions; | |
using Utilities.Patterns; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.ComponentModel.DataAnnotations; | |
namespace Utilities.Validation.ExtensionMethods | |
{ | |
public static class ValidationExtensions | |
{ | |
/// <summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#OS junk files | |
[Tt]humbs.db | |
*.DS_Store | |
#Visual Studio files | |
*.[Oo]bj | |
*.user | |
*.aps | |
*.pch | |
*.vspscc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class BenchmarkExtension { | |
public static void Times(this int times, string description, Action action) { | |
Stopwatch watch = new Stopwatch(); | |
watch.Start(); | |
for (int i = 0; i < times; i++) { | |
action(); | |
} | |
watch.Stop(); | |
Console.WriteLine("{0} ... Total time: {1}ms ({2} iterations)", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[DebuggerDisplay("Status: {Status}")] | |
public class OperationStatus | |
{ | |
public bool Status { get; set; } | |
public int RecordsAffected { get; set; } | |
public string Message { get; set; } | |
public Object OperationId { get; set; } | |
//Store simple string for exception message to avoid any possible serialization issues | |
public string ExceptionMessage { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeClass { | |
public void SomeMethod() { | |
this.Log().Info("Here is a log message with params which can be in Razor Views as well: '{0}'".FormatWith(typeof(SomeClass).Name)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var variable = 1; | |
100000.Times("Get variable name", () => GetName(new {variable})); | |
100000.Times("Get variable name", () => GetNameCached(new { variable})); | |
100000.Times("Get variable name", () => GetNameExpression(() => variable)); | |
100000.Times("Get variable name", () => GetNameIL(() => variable)); | |
} | |
public static string GetName<T>(T item) where T : class |
OlderNewer