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 AutoMapper; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace AutoMapperCondition | |
{ | |
class Program |
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 TaskExtensions | |
{ | |
public static async Task<T?> WithCancellationToken<T>(this Task<T> source, CancellationToken cancellationToken) | |
{ | |
var cancellationTask = new TaskCompletionSource<bool>(); | |
cancellationToken.Register(() => cancellationTask.SetCanceled()); | |
_ = await Task.WhenAny(source, cancellationTask.Task); | |
if (cancellationToken.IsCancellationRequested) |
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 Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Hosting; | |
namespace ConsoleApp15; | |
public static class Program | |
{ | |
public static async Task Main(string[] args) | |
{ | |
IHostBuilder hostBuilder = Host.CreateDefaultBuilder(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
Instead of this | |
return Db.Users.FirstOrDefaultAsync(x => x.EmailAddress == emailAddress); | |
do this | |
return Db.InvokeAsync(() => ...the query above...); | |
// Add the following methods to your DbContext |
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 Fluxor; | |
using Microsoft.Extensions.DependencyInjection; | |
var services = new ServiceCollection(); | |
services.AddFluxor(x => | |
{ | |
x.ScanAssemblies(typeof(Program).Assembly); | |
// CON: Need to explicitly register a reducer type for each feature state | |
x.ScanTypes( | |
typeof(ChangeCommonStateReducers<State1>), // Register this generic class |
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 Fluxor; | |
using Microsoft.Extensions.DependencyInjection; | |
var services = new ServiceCollection(); | |
services.AddFluxor(x => | |
{ | |
x.ScanAssemblies(typeof(Program).Assembly); | |
// PRO: No need to register lots of generic classes here | |
}); |
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
// Benchmarks | |
using BenchmarkDotNet.Attributes; | |
using LanguageExt; | |
using System.Collections.Immutable; | |
namespace MyImmutableArray; | |
[MemoryDiagnoser] | |
public class Benchmarks | |
{ |
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
// BenchmarkDotNet benchmarks to test the speed of .net framework immutable classes | |
// See this image for results => https://user-images.githubusercontent.com/3111981/165134368-5875560d-47ef-4627-b51f-854e0cf24d36.png | |
using BenchmarkDotNet.Attributes; | |
using System.Collections.Immutable; | |
namespace ConsoleApp20; | |
[MemoryDiagnoser] | |
public class BM |
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 Gambit.GameServer.Contracts; | |
using Gambit.GameServerIntegrationTests.Drivers; | |
namespace Gambit.GameServerIntegrationTests.Features.Users; | |
[Binding] | |
public class SignInStepDefinitions | |
{ | |
private readonly UserDriver UserDriver; | |
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.Collections.Concurrent; | |
using System.Reflection; | |
using CarePlace.Client.Services; | |
using Fluxor; | |
using MediatR; | |
namespace XXXXXXX.Client.ViewState; | |
public class ApiEffects | |
{ |
OlderNewer