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; | |
using System.Diagnostics; | |
using System.IO; | |
using System.IO.Compression; | |
using System.Linq; | |
using System.Runtime.Serialization; | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.Text; | |
using Comparers; |
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.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace Voron.Util | |
{ | |
public class LinkedDictionary<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IReadOnlyDictionary<TKey, TValue> | |
where TValue : class, new() | |
{ | |
private readonly TValue _deleteMarker = new TValue(); |
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.Runtime.CompilerServices; | |
using System.Threading.Tasks; | |
// The more evil version. :) | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
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 sealed class InMemoryFileProvider : IFileProvider | |
{ | |
private readonly string _json; | |
public InMemoryFileProvider(string json) | |
{ | |
_json = json; | |
} | |
public IFileInfo GetFileInfo(string subpath) => new FileInfo(_json); |
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
class Future<T> { | |
private resolver: (value: T) => void; // readonly | |
private rejecter: (error: Error) => void; // readonly | |
private _isCompleted: boolean = false; | |
constructor() { | |
this.promise = new Promise((resolve, reject) => { | |
this.resolver = resolve; | |
this.rejecter = reject; | |
}); |
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 static class Try | |
{ | |
public static Try<T> FromException<T>(Exception exception) => Try<T>.FromException(exception); | |
public static Try<T> FromValue<T>(T value) => Try<T>.FromValue(value); | |
public static Try<T> Create<T>(Func<T> func) => Try<T>.Create(func); | |
} | |
public sealed class Try<T> | |
{ | |
public static Try<T> FromException(Exception exception) => new Try<T>(exception, default, true); |
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.IdentityModel.Tokens.Jwt; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Security.Claims; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.IdentityModel.Protocols; | |
using Microsoft.IdentityModel.Protocols.OpenIdConnect; | |
using Microsoft.IdentityModel.Tokens; |
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
Simple WebAPI app with Console client that shows that async methods do release threads to the thread pool. |
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
/// <summary> | |
/// Creates a custom object based on the json values. | |
/// </summary> | |
/// <typeparam name="T">The object type to convert.</typeparam> | |
public abstract class JsonCreationConverter<T> : JsonConverter | |
{ | |
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | |
{ | |
if (reader.TokenType == JsonToken.Null) | |
return null; |
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.Threading.Tasks; | |
namespace Nito.AsyncEx | |
{ | |
/// <summary> | |
/// A progress implementation that sends progress reports to an observer stream. Optionally ends the stream when the task completes. | |
/// </summary> | |
/// <typeparam name="T">The type of progress value.</typeparam> | |
internal sealed class ObserverProgress<T> : IProgress<T> |