Skip to content

Instantly share code, notes, and snippets.

View dcomartin's full-sized avatar

Derek Comartin dcomartin

View GitHub Profile
public class ClassC
{
private string? _state;
public async Task<int> NotThreadSafe(string state)
{
_state = state;
return _state.Length;
}
}
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Xunit;
namespace Tests
{
public class ScopedLifetimeTest
{
[Fact]
{
"$type": "System.Collections.Generic.List`1[[System.String, System.Private.CoreLib]], System.Private.CoreLib",
"$values": [
"CodeOpinion",
"Derek Comartin"
]
}
{
"$type": "System.Collections.Generic.List`1[[System.String, mscorlib]], mscorlib",
"$values": [
"CodeOpinion",
"Derek Comartin"
]
}
{
"year": 2020,
"month": 6,
"day": 24,
"calendar": 0,
"nanoOfDay": 67807802138300,
"offsetSeconds": -14400,
"zone": "America/Detroit"
}
{
"Offset": {
"Seconds": -14400,
"Milliseconds": -14400000,
"Ticks": -144000000000,
"Nanoseconds": -14400000000000
},
"Zone": {
"Id": "America/Detroit",
"MinOffset": {
using DotNetCore.CAP;
using Microsoft.Extensions.Logging;
namespace CAPDemo
{
public class HelloWorldReceiver : ICapSubscribe
{
private readonly ILogger<HelloWorldReceiver> _logger;
public HelloWorldReceiver(ILogger<HelloWorldReceiver> logger)
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using DotNetCore.CAP;
using MySql.Data.MySqlClient;
namespace CAPDemo.Controllers
{
public class HomeController : Controller
{
private readonly ICapPublisher _capPublisher;
using DotNetCore.CAP;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace CAPDemo
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNetCore.CAP" Version="3.0.4" />
<PackageReference Include="DotNetCore.CAP.MySql" Version="3.0.4" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="3.0.4" />