Skip to content

Instantly share code, notes, and snippets.

Derek Comartin dcomartin

Block or report user

Report or block dcomartin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View useBlocking.cs
using Ben.Diagnostics;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace DetectAsync
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
View csproj.xml
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Ben.BlockingDetector" Version="0.0.3" />
</ItemGroup>
View SyncOverAsync.cs
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace DetectAsync
{
public class BlockingDetectorController : Controller
{
[HttpGet("/sync-over-async")]
public string SyncOverAsyncMethod()
{
View base.cs
mapBuilder.Map<AccountEvent>().As((accountEvent, balance) =>
{
// do something
});
View condition.cs
mapBuilder
.Map<Deposited>()
.When(deposited => deposited.Amount > 100)
.As(deposited =>
{
// do something
});
View map.cs
public class BalanceProjection
{
private readonly IEventMap<Balance> _map;
public Balance Balance { get; } = new Balance(0, DateTime.UtcNow);
public BalanceProjection(IStreamStore streamStore, StreamId streamId)
{
var mapBuilder = new EventMapBuilder<Balance>();
mapBuilder.Map<Deposited>().As((deposited, balance) =>
{
View balance.cs
public class Balance
{
public Balance(decimal amount, DateTime asOf)
{
Amount = amount;
AsOf = asOf;
}
public decimal Amount { get; private set; }
public DateTime AsOf { get;private set; }
View csproj.xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SqlStreamStore" Version="1.1.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
View program.cs
using System;
using System.Threading.Tasks;
using SqlStreamStore.Streams;
namespace SqlStreamStore.Demo
{
static class Program
{
private static InMemoryStreamStore _streamStore;
private static Account _account;
View projection.cs
using System;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using SqlStreamStore.Streams;
namespace SqlStreamStore.Demo
{
public class BalanceProjection
{
You can’t perform that action at this time.