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.ComponentModel; | |
public sealed class StackEnumerator<T> : IDisposable | |
{ | |
private readonly Stack<IEnumerator<T>> stack = new Stack<IEnumerator<T>>(); | |
private IEnumerator<T> current; | |
public bool MoveNext() |
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 Newtonsoft.Json; | |
using Newtonsoft.Json.Linq; | |
using Newtonsoft.Json.Serialization; | |
public sealed class DerivedDiscriminatorConverter<TBase> : JsonConverter where TBase : class | |
{ | |
private readonly string discriminatorProperty; | |
private readonly Dictionary<object, Type> typeByDiscriminator = new Dictionary<object, Type>(); |
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 LanguageUtils | |
{ | |
public static TInterface ExplicitImplementation<TBase, TInterface>(TBase @this) | |
where TBase : TInterface | |
where TInterface : class | |
{ | |
return (TInterface)new ExplicitImplementationProxy(typeof(TBase), @this).GetTransparentProxy(); | |
} | |
private sealed class ExplicitImplementationProxy : RealProxy, IRemotingTypeInfo |
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
/// <summary> | |
/// Hooks into the key messages at a low level and replaces all characters with '*', maintaining a separate SecureString to store the actual password. | |
/// </summary> | |
[UserRepositoryItem("Register")] | |
public sealed class RepositoryItemPasswordEdit : RepositoryItemTextEdit | |
{ | |
static RepositoryItemPasswordEdit() | |
{ | |
Register(); | |
} |
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 System.Web; | |
using System.Web.Mvc; | |
public class DerivedDiscriminatorModelBinder<T> : DefaultModelBinder where T : class | |
{ | |
private readonly string discriminatorPropertyName; | |
private readonly Dictionary<object, Type> mapping = new Dictionary<object, Type>(); |
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.ComponentModel; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
using System.Runtime.CompilerServices; | |
using System.Threading.Tasks; | |
using Techsola.Threading; |
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.ComponentModel; | |
using System.Linq; | |
using System.Linq.Expressions; | |
public sealed class ExpressionComparer : IEqualityComparer<Expression> | |
{ | |
public NameComparison CompareLambdaNames { get; set; } | |
public NameComparison CompareParameterNames { 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
/// <summary> | |
/// Calculates the hash code for a substring without allocating the substring. | |
/// </summary> | |
// Identical to String.GetHashCode except for custom start and stop | |
// I have unit tests on this | |
[SecuritySafeCritical] | |
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] | |
public static int GetHashCode(this string str, int startIndex, int length) | |
{ | |
if (str == null) throw new ArgumentNullException("str"); |
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
// #define ASYNC_SIMULATOR_RAISE_IDLE - Disabled due to conflict with XtraReportEx.CreateDocument(true) and AsyncWaitData, and no known benefit | |
using System; | |
using System.ComponentModel; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
using System.Runtime.InteropServices; | |
using System.Threading; |
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
// MIT license, copyright 2015 Joseph N. Musser II | |
using System; | |
using System.Collections.Generic; | |
using System.Reflection; | |
using System.Reflection.Emit; | |
using System.Runtime.CompilerServices; | |
namespace jnm2 | |
{ |
OlderNewer