This file contains hidden or 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 static class Expires | |
| { | |
| public static void Set(int seconds) | |
| { | |
| var response = WebOperationContext.Current.OutGoingResponse; | |
| if(response != null) | |
| { | |
| var expires = DateTime.UtcNow.AddSeconds(seconds).ToEpireString(); |
This file contains hidden or 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 static void Shuffle<T>(this T[] array, Random random) | |
| { | |
| int n = array.Length; | |
| while (n > 1) | |
| { | |
| int k = random.Next(n--); | |
| T temp = array[n]; | |
| array[n] = array[k]; | |
| array[k] = temp; | |
| } |
This file contains hidden or 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 static Guid Hash(params object[] args) | |
| { | |
| var composite = ""; | |
| foreach (var a in args) | |
| { | |
| composite += a.ToString(); | |
| } | |
| Guid result; | |
| using(var md5 = new MD5CryptoServiceProvider()) |
This file contains hidden or 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 static class SymmetricExtensions | |
| { | |
| private const ushort _iteration = 1000; | |
| private const int _saltSize = 8; | |
| public static byte[] Encrypt(this byte[] plainTextData, string password) | |
| { | |
| byte[] encryptedData = null; | |
| using (var provider = new RijndaelManaged()) | |
| { |
This file contains hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |