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.Threading.Tasks; | |
namespace System.Collections.Concurrent | |
{ | |
public static class ConcurrentDictionaryExtensions | |
{ | |
/// <summary> | |
/// Provides an alternative to <see cref="ConcurrentDictionary{TKey, TValue}.GetOrAdd(TKey, Func{TKey, TValue})"/> that disposes values that implement <see cref="IDisposable"/>. | |
/// </summary> |
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.Concurrent; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Reflection; | |
using System.Runtime.Loader; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc.ApplicationParts; | |
using Microsoft.AspNetCore.Mvc.Infrastructure; |
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 t1 = DoFooAsync(obj); | |
var t2 = DoBarAsync(obj); | |
var t = await WhenAnySuccessOrAllFail(t1, t2); | |
async Task WhenAnySuccessOrAllFail(params Task[] tasks) | |
{ | |
var remaining = new List<Task>(tasks); | |
while (remaining.Count > 0) |
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
// Question: Implement a route matching enging | |
// Given a list of routes as a list of strings and a matching route, build a route matching engine | |
// that returns true if a path matches. | |
const routes = ['/foo/blah/bar', '/foo', '/products'] | |
function buildTrie(routes) { | |
var root = { path: {} }; | |
for (var route of routes) { | |
var node = root; |
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.Collections.Immutable; | |
using System.IO; | |
using System.Linq; | |
using System.Reflection; | |
using System.Runtime.Loader; | |
using System.Threading; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; |
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.Reflection; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.AspNetCore.Mvc.ApplicationParts; | |
using Microsoft.AspNetCore.Mvc.Infrastructure; |
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.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.DependencyInjection; | |
namespace ConsoleApp38 | |
{ | |
class Program | |
{ | |
[ThreadStatic] |
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
<?xml version="1.0" encoding="utf-8"?> | |
<!-- See: https://github.com/mono/linker/blob/master/src/linker/README.md#syntax-of-xml-descriptor --> | |
<linker> | |
<assembly fullname="Microsoft.Extensions.Hosting"> | |
<type fullname="Microsoft.Extensions.Hosting.Internal.ApplicationLifetime" /> | |
<type fullname="Microsoft.Extensions.Hosting.Internal.ConsoleLifetime" /> | |
<type fullname="Microsoft.Extensions.Hosting.ConsoleLifetimeOptions" /> | |
<type fullname="Microsoft.Extensions.Hosting.Internal.Host" /> | |
<type fullname="Microsoft.Extensions.Hosting.HostOptions" /> | |
</assembly> |
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.Concurrent; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace ConsoleApp25 | |
{ | |
class Program | |
{ | |
static async Task Main(string[] args) |
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
services.AddOptions<OpenIdConnectOptions>() | |
.Configure<IOIDCPipelineStore, IHttpContextAccessor>((oidcPipelineStore, accessor, options) => | |
{ | |
options.ProtocolValidator = new MyOpenIdConnectProtocolValidator(oidcPipelineStore, accessor) | |
{ | |
RequireTimeStampInNonce = false, | |
RequireStateValidation = false, | |
RequireNonce = true, | |
NonceLifetime = TimeSpan.FromMinutes(15) | |
}; |