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
[HttpGet(Name = "GetWeatherForecast")] | |
public async Task<IEnumerable<WeatherForecast>> Get() | |
{ | |
//pass this around to long running tasks | |
CancellationToken cancellationToken = HttpContext.RequestAborted; | |
if (cancellationToken.IsCancellationRequested) | |
{ | |
throw null!; // or whatever you want to do | |
} | |
return await DoItSlowly(++_callerCount, cancellationToken); |
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 Microsoft.Extensions.Configuration; | |
var builder = new ConfigurationBuilder() | |
.SetBasePath(Directory.GetCurrentDirectory()) | |
.AddJsonFile("appsettings.json", optional: false); | |
var options = new MyImageProcessingOptions(); | |
var config = builder.Build(); |
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 BenchmarkDotNet.Attributes; | |
namespace benchmarks | |
{ | |
[MemoryDiagnoser] | |
public class ThrowHelperBenchmarks | |
{ | |
// [GlobalSetup] |
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 Func<T1, TResult> CompileConstructor<T1, TResult>() | |
{ | |
var type1 = typeof(T1); | |
var parameter1 = Expression.Parameter(type1); | |
var constructor = typeof(TResult).GetConstructor(new Type[] { type1 }); | |
var body = Expression.New(constructor, parameter1); | |
var lambda = Expression.Lambda<Func<T1, TResult>>(body, parameter1); | |
var method = lambda.Compile(); | |
return method; | |
} |
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 class RunWithCacheCow | |
{ | |
private readonly HttpClient _client; | |
public RunWithCacheCow() | |
{ | |
var httpClientHandler = new HttpClientHandler() | |
{ | |
Credentials = new NetworkCredential("test", "test"), | |
}; |
This file has been truncated, but you can view the full file.
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
<!-- | |
============================================================================================================================================ | |
C:\temp\consoleapp1\consoleapp1.csproj | |
============================================================================================================================================ | |
--> | |
<Project DefaultTargets="Build"> | |
<!-- | |
============================================================================================================================================ | |
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk"> | |
This import was added implicitly because the Project element's Sdk attribute specified "Microsoft.NET.Sdk". |
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> | |
/// Represents a JSON.net <see cref="JsonConverter"/> that serialises and deserialises a <see cref="Dictionary{TKey,TValue}"/>, where | |
/// <typeparamref name="TKey"/> is a non-primitive type, i.e. a type that is not a string, int, etc. | |
/// JSON.net uses the string representation of dictionary keys, which can cause problems with complex (non-primitive types). | |
/// You could override ToString, or add attributes to your type to overcome this problem, but the solution that this type | |
/// solves is for when you don't have access to the type being [de]serialised. | |
/// This solution was based on this StackOverflow answer (added the deserialisation part): https://stackoverflow.com/a/27043792/28901 | |
/// </summary> | |
/// <typeparam name="TKey">The type of the key. Normally a complex type, but can be anything. If it's a non complex type, then this converter isn't needd.</typeparam> | |
/// <typeparam name="TValue">The value</typeparam> |
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
void onCanvasDraw(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args) | |
{ | |
args.DrawingSession.Transform = _scale; | |
args.DrawingSession.Clear(Colors.Aquamarine); | |
using (var offscreenSession = _offscreenCanvas.CreateDrawingSession()) | |
{ | |
offscreenSession.Clear(Colors.Aquamarine); |
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
choco install chocolatey | |
choco install googlechrome | |
choco install 7zip | |
choco install vlc | |
choco install sublimetext3 | |
choco install paint.net | |
choco install tortoisesvn | |
choco install VirtualCloneDrive | |
choco install FoxitReader | |
choco install beyondcompare |
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.Diagnostics.CodeAnalysis ; | |
using System.Linq ; | |
using JetBrains.Annotations ; | |
// PLEASE DON'T MAKE ANYTHING PUBLIC IN THIS FILE. THIS FILE (AND JETBRAINS.ANNOTATIONS) IS INTENDED | |
// TO BE INCLUDED AS A LINKED FILE INTO WHATEVER PROJECTS NEEDS THEM. |
NewerOlder