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() | |
| { | |
| using(var l = new ReaderWriterLockSlim()) | |
| { | |
| var tasks = Enumerable.Range(0,2).Select (i => | |
| Task.Run(() => | |
| { | |
| l.EnterUpgradeableReadLock(); | |
| try | |
| { |
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
| using System; | |
| using System.Collections.Generic; | |
| public class CharacterComparer : IEqualityComparer<char>, IEqualityComparer<string> | |
| { | |
| public static readonly CharacterComparer Ordinal = new CharacterComparer(StringComparer.Ordinal); | |
| public static readonly CharacterComparer OrdinalIgnoreCase = new CharacterComparer(StringComparer.OrdinalIgnoreCase); | |
| public static readonly CharacterComparer CurrentCulture = new CharacterComparer(StringComparer.CurrentCulture); | |
| public static readonly CharacterComparer CurrentCultureIgnoreCase = new CharacterComparer(StringComparer.CurrentCultureIgnoreCase); | |
| public static readonly CharacterComparer InvariantCulture = new CharacterComparer(StringComparer.InvariantCulture); |
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 JaroWinklerDistance | |
| { | |
| /* The Winkler modification will not be applied unless the | |
| * percent match was at or above the mWeightThreshold percent | |
| * without the modification. | |
| * Winkler's paper used a default value of 0.7 | |
| */ | |
| private const double WeightThreshold = 0.7; | |
| /* Size of the prefix to be concidered by the Winkler modification. |
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
| using System; | |
| using System.Collections; | |
| using System.Collections.Concurrent; | |
| using System.Collections.Generic; | |
| using System.Threading.Tasks; | |
| namespace CoreTechs.Common | |
| { | |
| public class BufferedEnumerable<T> : IEnumerable<T> | |
| { |
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
| var dt = DateTime.Parse("3/1/2015 12:07 AM", CultureInfo.CurrentCulture, DateTimeStyles.AssumeUniversal); | |
| var dto = new DateTimeOffset(dt); |
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
| <p> | |
| The password input below is using the "peek-password" directive. | |
| Focusing on the input will reveal the peek icon on the right side. | |
| Hovering the mouse over the peek icon will cause the password value to be visible. | |
| Try it! | |
| </p> | |
| <form ng-app="app" class="form-horizontal"> |
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 Base64Extensions | |
| { | |
| private static readonly Lazy<char[]> EncMap = | |
| new Lazy<char[]>(BuildEncodingMap); | |
| private static readonly Lazy<int[]> DecMap = | |
| new Lazy<int[]>(BuildDecodingMap); | |
| private const char Pad = '='; |
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 ConcurrentList<T> : IList<T>, IDisposable | |
| { | |
| private ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); | |
| private int _count = 0; | |
| public int Count | |
| { | |
| get | |
| { | |
| _lock.EnterReadLock(); |
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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using WebApplication9.Models; | |
| namespace WebApplication9 | |
| { | |
| public class DemoGettingUsersInSpecificRole | |
| { | |
| private readonly ApplicationDbContext _db; |
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 void Write(RecordBase record) | |
| { | |
| if (record == null) | |
| throw new ArgumentNullException("record"); | |
| // we have something to write | |
| var spec = Spec.GetRecordSpec(record); | |
| if (spec == null) | |
| throw new UnknownRecordTypeException("Unknown record type: " + record.GetType().FullName); |